Setting up my first developing environment, so bear with me. Running Mountain Lion, Ruby 1.9.3, Gems 1.8.25 and RVM 1.19.1.
Trying to get RSPEC up and running, but I keep getting an error. I think it has to do with my PATH, as most questions about this refer to the fact that their shell (Bash?) is looking in the wrong place.
Using this wonderful tutorial: http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/
I've tried running the simplest rspec files and get an error, so I tried just typing "spec" (no quotes) in the command-line. That gives me the error "-bash: spec: command not found" (no quotes).
Looked around stackoverflow and saw that the command was updated to "rspec" instead of "spec"? So when I type "rspec" (no quotes) into the command line I get this nonsense:
Evans-MacBook-Pro:~ Evan$ rspec
/Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file -- /Users/Evan/spec (LoadError)
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
Regarding previous answers I found to this question: my attempts to alter the .bashrc just left me confused about what the heck I was doing, and I don't think I got the syntax right (also it didn't work).
Any thoughts? Much appreciated!
Evan
Rspec assumes your specs in a spec/ directory which cannot be found. Try running
rspec spec_tutorial
Btw. this tutorial is pretty outdated. Try using rspec.info instead for example.
Related
I'm trying to use fastlane on Windows, which is installed from Bundler -- which is installed by Ruby Gem. But while running, some internal error of Ruby seems blocked the execution.
First, I went to Ruby Installer and installed Ruby+Devkit 3.0.2-1 (x64); then, I installed the Bundler and Fastlane using gem command. Error below happened when I was trying to execute them -- which I believed was not related to Bundler nor Fastlane:
C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:168:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:236:in `size_from_readline'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:66:in `size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:76:in `width'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane_core/lib/fastlane_core/print_table.rb:95:in `transform_output'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:335:in `print_plugin_information'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:316:in `load_plugins'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/commands_generator.rb:39:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/bin/fastlane:23:in `<top (required)>'
from C:/Ruby30-x64/bin/fastlane:23:in `load'
from C:/Ruby30-x64/bin/fastlane:23:in `<main>'
I'm using Windows 10 home version 20H2.
Rebooting the computer doesn't solve the problem.
I tried googling the question, but it seems that problem hasn't be reported (or be answered). I don't know where I can report the bug either.
What can I do? Any help would be appreciated!
I had this same error when I tried running bundle exec fastlane in git bash.
I got it working by running it in powershell instead.
I'm new to both Ruby and Sinatra/Padrino so I apologize if I'm missing something really simple.
I have Sinatra working fine, as I can build a very simple "hello" app and see it work.
I wanted to move on and generate a new Padrino project, but when I do this:
$ padrino g project foobar
I get this:
/Users/dave/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/ordered_hash.rb:3:in `<top (required)>': undefined method `add_builtin_type' for Psych:Module (NoMethodError)
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/dave/.rvm/gems/ruby-2.1.5/gems/padrino-gen-0.12.4/lib/padrino-gen.rb:3:in `<top (required)>'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/dave/.rvm/gems/ruby-2.1.5/gems/padrino-gen-0.12.4/bin/padrino-gen:12:in `<main>'
I have tried installing the Psych gem but this didn't change anything. I have no idea what to try next, or how to really interpret the error message. Any nudges in the right direction you can give me?
Bug reports show this may be an RVM issue.
I suggest changing from RVM to "ruby-install" and "chruby" because IMHO these are simpler, easier, and better at installing dependencies including psych and its libraries.
As joelparkerhenderson noted, the error message shows problems with gem files in the .rvm directory, suggesting some issue or conflict with rvm. Switching to system ruby solved the problem for me. I don't really need to use a specific version of ruby on this project, so that's a fine workaround for me.
I had this problem while using Ruby 2.1.5. After reading comments on here I realized it's not a RVM problem, but a ruby problem. I switched to 2.0.0-p576 and everything works. Psych must not be compatible with the new ruby versions.
However I don't understand how a different ruby version would cause this method to go missing. If anyone could explain that I would be grateful!
I ran into this using rbenv and padrino 0.13.0. Tried many versions of Ruby, including the system Ruby on OS X El Capitan, but found that that made no difference, so I'm now running the latest stable one (2.2.4).
Eventually I tried each version of the psych gem and found I could only get padrino g to work with an older version of the gem. Psych version 2.0.8 worked, while every newer version (up to the current 2.0.16) failed.
So: gem install psych -v=2.0.8 && gem uninstall psych -v '>= 2.0.9'
With me, after a lot of googling and reading various thread on S.O., it was only my rvm that was the problem. I was getting the rvm 'WARNING!' that rvm wasn't first in $PATH. You can check this with echo $PATH. Check out your ~/.bashrc see if there is anything like heroku toolbelt or linuxbrew, or whatever, loading themselves into your PATH at the FRONT i.e. PRE-PENDING your path, rather than APPENDING. This is indicated by something like export PATH="/usr/local/heroku/bin:$PATH". That sets heroku at the beginning of your PATH. Simply change it to export PATH="$PATH:/usr/local/heroku/bin".
I was trying to start a padrino project with activesupport, and this was causing problems. Changing to an earlier version of Ruby, as suggested in another thread, didn't cut it, because activesupport requires 2.2.0 or up.
Fixing my PATH, ensuring that rvm was initialized at the very beginning of the PATH, fixed my Padrino problem, and was able to initialize a project with the following command:
padrino g project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord -b
I know that's all a little off-tangent, but I think it's bound to help one or two people out there!
PS I'm using ruby 2.2.2p95 in this project folder.
A heads up that I'm in no way a Ruby expert...I just use it from time to time for basic scripting. I'm trying to use the RubyCocoa framework so that I can use additional commands in my Ruby script.
As an example, if I was to try something as explicit as this:
#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
require '/System/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/cocoa.rb'
puts "Hello, World"
I receive this error:
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- osx/objc/cocoa.rb (LoadError)
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /System/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/cocoa.rb:8:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from Test.rb:4:in `<main>'
I do have Homebrew installed on my Mac (running 10.10), but why does the require command go through to the Cellar folder? You can see I'm trying to use the 2.0 Ruby version from my Frameworks folder (the one in /usr/bin is still 1.9.3 (would also love for someone to explain how these versions differ and why)).
It goes through the Cellar folder because it is in your load path.
You can examine your load path by writing in your script
puts $:
Concerning your error message
You can use fully qualified path in require so
require '/System/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/cocoa.rb'
is correct.
And indeed in your error message you can see this line
from /System/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/cocoa.rb:8:in `<top (required)>'
So you correctly required your file
However from the first line of your error message.
usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- osx/objc/cocoa.rb (LoadError)
We can see ruby/osx/cocoa.rb tries to require another file. This one is different and found under osx/objc/cocoa.rb. So those files have similar names but are different.
And since it tries to require with require 'osx/objc/cocoa.rb' it fails because it does not know how to find it (not a fully qualified path here).
Maybe you can try to change the load path variable.
By adding the line:
$: << '/System/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/'
It might work but I’m not sure since I don’t know where that osx/obj folder is located on your machine.
you might want to take some time to clean your ruby installation and maybe instead a fresh ruby using rvm or rbenv (I prefer rbenv)
After installing RVM the other day I can no longer use compass watch as I could.
I've tried updating the system, installing compass again, as well as sass, all to no avail.
Here's the error I get in Terminal:
/Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:16:in `build': /Gemfile not found (Bundler::GemfileNotFound)
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/gems/compass-0.12.2/bin/compass:26:in `<top (required)>'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/compass:23:in `load'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/compass:23:in `<main>'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
I've attempted to use bundle update sass-rails per this question, but get the error Could not locate Gemfile
I've also tried to follow the advise here to no avail.
At this point I'm a bit lost. I'm brand new to the Ruby world as well as RVM, and am not the most proficient Terminal user to begin with.
Thanks for any assistance or insight-
/Gemfile not found was a bug in older version of rubygems-bundler gem, run:
rvm #global do gem update rubygems-bundler
and it should work fine
I don't have the answer as to how to fix the problem itself, but I did go through with simply removing it for the time being.
I used rvm implode to remove rvm from my machine per this post.
Everything worked fine after that. Unfortunately that'll delay my experimenting with the Ruby world for a little while longer as I don't have time to figure out how to have RVM without the complications it seemingly brought.
Best,
Hello the clever people of Stackoverflow.
I am trying to right a little JSON script. But the JSON Gem does not seem to be working. Just by having the code:
require 'rubygems'
require 'json'
I get the error:
./json.rb:5: undefined method `search' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from places.rb:2
I don't have any other code in the file. I have unistalled the gem and reinstalled. But the same error, I can't find what the problem is?
I feel like all I do on this site is ask for help, but I do only come here as a last resort, and if there is anything I can do please let me know in return
Thanks
Charlie
Do you have a json.rb in the same directory as the places.rb? Try renaming that to something else.
I upgraded to the last Ruby 1.9.2 using RVM and re-installed Gems and its working fine, if anyone runs into the same problem would recommend doing this!