I've successfully installed my ruby gem to a subdirectory of ~ using the --user-install option to gem. I can now see it under ~/.gem/ruby/1.8/gems/.
However, I'm unable to require it from my script:
./public_html/tt_web/index.cgi:2:in `require': no such file to load -- mbox (LoadError)
from ./public_html/tt_web/index.cgi:2
I added ~/.gem/ruby/1.8/bin to my PATH variable per the information here (and I've verified it actually worked with echo $PATH).
What else do I need to load gems from a custom path?
Here is the output of gem env, if it helps:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/elliott/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gempath" => ["/home/elliott/.gem", "/var/lib/gems/1.8"]
- "install" => "--user-install"
- REMOTE SOURCES:
- http://rubygems.org/
Well, I have no idea why this works, but adding require 'rubygems' to the top of my code fixed everything. Perhaps someone else could still shine some light on why, but I'm just happy it's working now :)
Related
I wrote a homework assignment on my Mac at home and am now trying to run it on the Linux machines at school (where it will be graded) and am getting:
.rb:1:in `require': no such file to load -- socket (LoadError)
Obviously I am trying to use Ruby's socket class:
require 'socket'
Checking the schools ruby version I see: ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
Shouldn't this version of the sockets? Am I doing something wrong? Anyway to get this to work?
gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/devans/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I have Ruby installed on my work PC 1.9.3 version and Gem 1.8.24 but when I try to install Rails I get the following error:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - C:/Users/B"k"nyi Szabolcs
Can I fix this without creating a new Windows User?
Thanks for the help in advance.
My Windows user folder name is : Bökönyi Szabolcs
gem env says:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby193/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby193/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It seems I figured it out and the only problem was with the accent so instead of SET HOME %USERPROFILE% I used SET HOME="C:/Users/Bökönyi Szabolcs" and now the gem install rails works.
I have this error loading a ruby file:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- midiator (LoadError)
RubyGems Environment:
RUBYGEMS VERSION: 1.3.6
RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
RUBY EXECUTABLE: /usr/local/bin/ruby
EXECUTABLE DIRECTORY: /usr/local/bin
RUBYGEMS PLATFORMS:
ruby
x86-darwin-9
GEM PATHS:
/usr/local/lib/ruby/gems/1.8
/Users/pableras/.gem/ruby/1.8
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:benchmark => false
:backtrace => false
:bulk_threshold => 1000
I had a lot of problems tu install rubygems and now I have problems again with midiator gem. I think something is not well configured. It is like the paths are not properly configured (Midiator gem is installed), but I do not know how to fix this.
Turning this into an answer as it solved the problem:
Is it listed when you do gem list?
How can I delete the second path (/home/tom/.gem/ruby/1.8) of GEM PATHS: ?
Here's the output of $ gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/tom/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
I appreciate the help!
Override in your ~/.bashrc file?
#in ~/.bashrc
export GEM_PATH=/usr/lib/ruby/gems/1.8
Feels kind of hacky though.
You can’t! I also wanted to do it, and haven’t found a way. Then I looked for in RubyGems source (at github.com) and learned that it tries to get the path from etc/gemrc and ~/.gemrc. If it fails (and fails GEM_PATH environment variable too), it assumes ~/.gem to be the default path.
Therefore, Max William is right, and you have either to export GEM_PATH or to create a ~/.gemrc. And it’s not a hack, for sure! :-)
Hope to have cleared things a bit!
This is driving me crazy. I run into this every now and then on a new ubuntu/debian server.
Basically I can't do a exec! through net-ssh. Note, that I can require 'net/ssh' perfectly fine.
sample code
require 'rubygems'
require 'net/ssh'
Net::SSH.start('my.random.box', 'myuser', :forward_agent => "true") do |ssh|
#output = ssh.exec("hostname")
#puts output
output = ssh.exec!("hostname")
puts stdout
end
relevant system environment info
me#box:~$ gem list | grep net-ssh
net-ssh (2.0.11)
me#box:~$ which ruby
/usr/bin/ruby
me#box:~$ which gem
/usr/bin/gem
cyn0n#spicetrader:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/me/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
A couple of things to try:
Verify that the exec! method is in the source.
Check both gem repositories to make sure there isn't an older net-ssh version in there. gem list has some oddities; it's more straightforward to just go into the directories and see what's there.
require the current version in your script.
require 'rubygems'
gem 'net-ssh', '=2.0.11'
require 'net-ssh'