JoshCheek / seeing_is_believing

Displays the results of every line of code in your file
1.3k stars 54 forks source link

Fails to "inception" with a specified filename #70

Closed JoshCheek closed 8 years ago

JoshCheek commented 8 years ago
# Dir.chdir '/users/josh'  # <-- works if you uncomment this

require 'seeing_is_believing'
result = SeeingIsBelieving.call("
  [:a, :b, :c].each do |i|
    i.upcase
  end
  ", filename: './program.rb'
).result
# =>

# ~> Errno::ENOENT
# ~> No such file or directory @ unlink_internal - ./program.rb
# ~>
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/evaluate_by_moving_files.rb:79:in `delete'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/evaluate_by_moving_files.rb:79:in `set_back_to_initial_conditions'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/evaluate_by_moving_files.rb:52:in `block in call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/hard_core_ensure.rb:38:in `invoke_ensure'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/hard_core_ensure.rb:16:in `ensure in call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/hard_core_ensure.rb:16:in `call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/hard_core_ensure.rb:4:in `call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/evaluate_by_moving_files.rb:44:in `call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing/evaluate_by_moving_files.rb:24:in `call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing.rb:44:in `block in call'
# ~> /Users/josh/.rubies/ruby-2.3.0/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing.rb:38:in `call'
# ~> /Users/josh/.gem/ruby/2.3.0/gems/seeing_is_believing-3.0.0.beta.7/lib/seeing_is_believing.rb:27:in `call'
# ~> /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20160708-3858-ywlk2j/program.rb:4:in `<main>'
JoshCheek commented 8 years ago

This isn't technically a bug, it's doing what it's supposed to (running the code from the invoker's CWD). It's unexpected because the CWD happens to be root, and the user does not have permissions to save files there. Probably the right thing to do is update editor integrations to cd to the project root or to a temp dir. Maybe the right thing to do is provide a "you figure it out, SiB" flag, since there's some reasonable default behaviour that can be handled by, eg the binary, rather than figuring out how to implement it in every editor that invokes it.

JoshCheek commented 8 years ago

Closing because this a duplicate of #45