SciRuby / rubex

rubex - A Ruby-like language for writing Ruby C extensions.
BSD 2-Clause "Simplified" License
451 stars 21 forks source link

Error when using rubex from command line #46

Closed v0dro closed 6 years ago

v0dro commented 6 years ago

There is a runtime error if using Rubex from the command line after installation.

Here's the error:

➜  ~ git:(master) rubex no_gil.rubex 
/home/sameer/.rvm/gems/ruby-2.3.3/gems/rubex-0.1.1/lib/rubex/constants.rb:19:in `<module:Rubex>': uninitialized constant Rubex::DataType::Char (NameError)
    from /home/sameer/.rvm/gems/ruby-2.3.3/gems/rubex-0.1.1/lib/rubex/constants.rb:1:in `<top (required)>'
    from /home/sameer/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /home/sameer/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /home/sameer/.rvm/gems/ruby-2.3.3/gems/rubex-0.1.1/lib/rubex.rb:3:in `<top (required)>'
    from /home/sameer/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /home/sameer/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /home/sameer/.rvm/gems/ruby-2.3.3/gems/rubex-0.1.1/bin/rubex:3:in `<top (required)>'
    from /home/sameer/.rvm/gems/ruby-2.3.3/bin/rubex:23:in `load'
    from /home/sameer/.rvm/gems/ruby-2.3.3/bin/rubex:23:in `<main>'
    from /home/sameer/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
    from /home/sameer/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'
shaunakpp commented 6 years ago

I'll have a look this weekend, hopefully, sooner!

shaunakpp commented 6 years ago

Ah! I think I've figured it out. Are you, by any chance, cd ing into the spec/fixtures/no_gil directory and then running rubex no_gil.rubex?

v0dro commented 6 years ago

No. The file is in the home directory ~/.

shaunakpp commented 6 years ago

Got it. #56 should fix the issue

shaunakpp commented 6 years ago

So, I found some interesting bits when fixing this issue. I was using pry heavily for debugging this issue and whenever I did binding.pry and then called Dir.pwd it used to show me the directory from where I've called rubex no_gil.rubex and not the directory of the file where binding.pry was written.

This led to me scratching my head for couple of hours before understanding that inorder to have context relative to the file I've written binding.pry I need to wrap it in Dir.chdir

Dir.chdir(File.dirname(File.dirname(__FILE__))) do
  binding.pry
end
v0dro commented 6 years ago

Haha good find! Thank you :)