Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor writes to file (or fails to) #4

Open
ghazel opened this issue Feb 17, 2014 · 3 comments · May be fixed by #23
Open

Preprocessor writes to file (or fails to) #4

ghazel opened this issue Feb 17, 2014 · 3 comments · May be fixed by #23

Comments

@ghazel
Copy link

ghazel commented Feb 17, 2014

The C::Preprocessor attempts to write a temp file in the directory where the input file is. This is problematic for system includes where the user does not have permission to write. (i.e. C::Preprocessor.new.preprocess_file('/usr/include/math.h')) Yes, pwd can be set manually, but I can't help thinking it would be better to just send the input data to the compiler over stdin.

That is, if the Preprocessor isn't going to be entirely replaced with ruby code.

@oggy
Copy link
Owner

oggy commented Feb 18, 2014

Looks to me like it should be writing to the temp directory (it's doing Tempfile.open, which I believes writes to this location).

Are you not seeing this?

@ghazel
Copy link
Author

ghazel commented Feb 18, 2014

$ irb
1.9.3p286 :001 > require 'cast'
 => true 
1.9.3p286 :002 > C::Preprocessor.new.preprocess_file('/usr/include/math.h')
Errno::ENOENT: No such file or directory - /usr/include/cast-preprocessor-input.20140218-12133-xon498.c.lock
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:346:in `rmdir'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:346:in `rmdir'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:338:in `ensure in locking'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:338:in `locking'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:144:in `block in initialize'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tmpdir.rb:133:in `create'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:134:in `initialize'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:316:in `new'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tempfile.rb:316:in `open'
    from /Users/ghazel/.rvm/gems/ruby-1.9.3-p286/gems/cast-0.2.1/lib/cast/preprocessor.rb:30:in `preprocess'
    from /Users/ghazel/.rvm/gems/ruby-1.9.3-p286/gems/cast-0.2.1/lib/cast/preprocessor.rb:45:in `block in preprocess_file'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/fileutils.rb:125:in `chdir'
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/fileutils.rb:125:in `cd'
    from /Users/ghazel/.rvm/gems/ruby-1.9.3-p286/gems/cast-0.2.1/lib/cast/preprocessor.rb:44:in `preprocess_file'
    from (irb):2
    from /Users/ghazel/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in `<main>'
1.9.3p286 :003 > 

@oggy
Copy link
Owner

oggy commented Feb 18, 2014

Ah - got it. Yeah that seems reasonable.

byteit101 added a commit to byteit101/cast that referenced this issue Oct 1, 2022
1. Don't delete the preprocessor file before running cpp
2. Use the system temp dir, not the location (Fixes oggy#4)
@byteit101 byteit101 linked a pull request Oct 1, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants