I installed fxruby using
$sudo port install rb-fxruby
As suggested in the book.
It works, my hello world program worked correctly.
Now, though, other code that I have written is broken, whenever I try to use any code that relies on a gem, it does not work. When I do
$ruby -e "require 'rubygems'"
in my code, it gives
"LoadError: no such file to load — rubygems"
When I set my RUBYOPT="rubygems" in my .bash_profile
$ruby -e "puts 'hello world'"
ruby: no such file to load -- ubygems (LoadError)
(it says 'ubygems' without the 'r' on the front, not sure why)
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00351.html suggests I check my gem location against my ruby location, I get:
$cat `which gem` | head -n 1
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
$ls -l `which ruby`
-rwxr-xr-x 2 root admin 12680 Feb 7 03:40 /opt/local/bin/ruby
I assume this means that the gems are confused, but not sure how to remedy it. Any ideas? It sucks not having gems.
---UPDATE---
Forgot to list versions:
$which gem
/usr/bin/gem
$gem --version
1.3.5
$ruby --version
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9]
If you installed rb-fxruby via macport it will install the macport ruby as well.
$ port info rb-fxruby
...
Library Dependencies: ruby, fox, fxscintilla
...
But as you can see rb-rubygems (the macport version of rubygems) is not listed as a dependency, so you will have to install it manually.
$ sudo port install rb-rubygems
should do it for you.
It looks like you are trying to use the Apple-supplied gem that works with the Apple-supplied ruby. Did you install the MacPorts version?
sudo port install rb-rubygems
/opt/local/bin/gem
Related
I have installed ruby 1.9.3 in my Ubuntu 12.04 machine following the instructions in https://github.com/postmodern/ruby-install and executing the following command:
sudo ruby-install ruby 1.9.3
I was assuming this would link from my /usr/bin or somewhere else visible from my path ruby or gem, but it doesn't. When I try for example: gem install bundler, I get:
sudo: gem: command not found
It also can't find ruby when I try ruby -v.
If I install with sudo apt-get install ruby1.9.3, I'm able to execute both ruby and gem:
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.11
I was expecting from ruby-install the same output I got from apt-get. Am I looking in the wrong place? How do I run ruby and gem after installing with ruby-install?
I know there are other installers for ruby like rvm and rbenv, but I'm following some installations instructions and they clearly instruct to use ruby-install.
Thanks in advance!
OK, found the answer.
After running
sudo ruby-install ruby 1.9.3
the last line from the log is:
>>> Successfully installed ruby 1.9.3-p547 into /opt/rubies/ruby-1.9.3-p547
Which I have no excuse for not paying attention to since it's in bold colourfull letters.
Erm, anyway, adding /opt/rubies/ruby-1.9.3-p547 to the PATH makes ruby and gem work.
export PATH=$PATH:/opt/rubies/ruby-1.9.3-p547/bin
I feel like a compelte idiot, but I've been wrking on this all day and getting no where.
I've restarted several times trying to get a full install of Ruby on my OSX environment, RVM, Brew, Ruby: and every time I get through to the Ruby install it bottoms out on the rubygems install.
The reason I'm having to start again is that the RVM wouldn't update in Jewelerybox after my first successfull install (used a packaged all-in-one RubyInstaller) so I couldn't manage my gems - a problem caused by the initial Ruby install on the system living in the /usr/local and not under my own directory. To fix this I uninstalled all my Ruby stuff and started again.
All ok until the ruby compiler started gacking on the rubygems install section when installing ruby 2.0.0. Checking out the OSX system files under usr/bin I see that rubygems isn't there either (it should be present by default on OSX). Any ideas? (note that XCode is up to date and has command line tools installed)
Last attempt was:
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm remove 2.0.0
$ rvm install ruby-2.0.0
. . . which fires the following error:
[2013-03-19 23:21:50] /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
Exception `LoadError' at /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1073 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/ruby
mkdir -p /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0
...
install -c -m 0755 /var/folders/nq/wkj89k854tl0w97n68qdn820pzk_51/T/gem.84634 /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/bin/gem
rm /var/folders/nq/wkj89k854tl0w97n68qdn820pzk_51/T/gem.84634
ERROR: While executing gem ... (NoMethodError)
undefined method `fu_stream_blksize' for #<Gem::Commands::SetupCommand:0x007ffd0e054818>
Installing RubyGems
Installing gem executable
I had the exact same error installing ruby v2 within rvm today. I was in a user account on Ubuntu who needed to use 'sudo' -- and enter my account password for sudo -- in order to install OS dependencies.
Your question mentions running rvm requirements to install dependencies. That seems to be new behavior in rvm, as of v1.19. It seemed to install a bunch of dependencies just fine. But then installing ruby bombed.
In earlier rvm versions, typing rvm requirements would just list the dependencies for rvm and for ruby, as in Archonic's answer.
I typed rvm implode and then started over with:
\curl -L https://get.rvm.io | bash -s 1.18.21
source /home/deploy/.rvm/scripts/rvm
rvm requirements
At that point I could install the libraries/tools that rvm said I needed for rvm and ruby, and then rvm install ruby-2.0.0-p0 succeeded.
I believe the issue is where RVM places your dependencies - global vs your user folder. From a book called "Agile development with rails":
First, you’ll need to make sure you have Xcode 3 or later installed...
$ xcodebuild -version
If you have Xcode version 3 installed, you’ll need to install the Git version control system separately. Verify your installation by running the following command:
$ git --version
Next, install RVM itself:
$ curl -L https://get.rvm.io | bash -s stable
Exit your command window or Terminal application and open a new one. This causes your .bash_login to be reloaded. Execute the following command, which provides additional installation instructions tailored to your specific operating system:
$ rvm requirements
Look for the line that tells you how to install the necessary OS dependencies for Ruby (MRI). Once you complete those instructions, you can proceed to install the Ruby interpreter itself:
$ rvm install 2.0.0
The preceding step will take a while as it downloads, configures, and compiles the necessary executables. Once it completes, use that environment, and install rails:
$ rvm use 2.0.0
$ gem install rails --version 4.0.0.beta1 --no-ri --no-rdoc
With the exception of the rvm use statement, each of the above instructions need only be done once. The rvm use statement needs to be repeated each time you open a shell window. The use keyword is optional, so you can abbreviate this to rvm 2.0.0. You can also choose to make it the default Ruby interpreter for new terminal sessions with the following command:
$ rvm --default 2.0.0
You can verify successful installation using the following command:
$ rails -v
If you have trouble, try the suggestions listed under the Troubleshooting Your Install heading on the rvm site.
Hope that does it for you!
This worked for me:
rvm get head
rvm requirements
rvm install ruby-2.0
I'm on Ubuntu 11.04 with ruby 1.9.2p180 installed from source using rvm. When I install a gem that makes a command-line binary, links are not made. For example, when I install the passenger gem, /var/lib/gems/1.9.2/bin/passenger is installed as expected and works, but a symbolic link is not made from /usr/bin/passenger as expected.
update
actually I have the same problem with vendor ruby and gem (on a different 11.04 server that has never had rvm).
$ sudo gem install bundler
$ bundle
bash: bundle: command not found
$ type bundle
-bash: type: bundle: not found
$ ls -lF /var/lib/gems/1.8/bin/bundle
-rwxr-xr-x 1 root root 383 2011-08-13 19:49 /var/lib/gems/1.8/bin/bundle*
RVM installation should be self-contained, which means it won't create symlinks out of the RVM directory. That should not be problem, though, as passenger binary should be added to path automatically by RVM.
Basically it should work like this:
$ rvm use ruby-1.9.2-p290
$ which gem
~/.rvm/rubies/ruby-1.9.2-p290/bin/gem
$ gem install passenger
$ which passenger
~/.rvm/gems/ruby-1.9.2-p290/bin/passenger
I would guess that you are using ubuntu's version of gem and ruby. rvm use ruby-1.9.2-p290 --default should fix that.
If rvm function is not accessible, add this to your .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
See https://rvm.beginrescueend.com/rvm/install/ for details.
I guess this can be your problem: installing rvm gems with sudo. Given you have the right privileges in your machine, this is not needed. But if you really need this, do rvmsudo gem install bundler instead.
I'm new to ubuntu, and might have had a couple of
false starts updating ruby / rails. I'm trying
to start clean by removing all versions of every
thing ruby from my system
I think I've installed everything through either
Synaptic, or aptitude purge, but I can still do the
following:
jwally#jwally-laptop:~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
jwally#jwally-laptop:~$ gem -v
1.3.7
jwally#jwally-laptop:~$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
but when I type "dpkg -l | grep ruby,
I only get the following:
rc ruby1.8-elisp 1.8.7.249-2 ruby-mode for Emacsen
thanks in advance
You may have installed an instance of Ruby without using Ubuntu's package system. Try:
which ruby
If this yields something other than /usr/bin/ruby (such as /usr/local/bin/ruby), then this is the case. Ubuntu can't uninstall locally installed stuff. You need to do that manually.
To see which package ruby is owned by run:
dpkg -S `which ruby`
If it can't find the package, then Ruby was installed outside of the Ubuntu package manager. You'll have to remove it manually.
I'll once again recommend this blog post for instructions on the best way to install Ruby on Ubuntu: Ubuntu, Ruby, RVM, Rails, and You.
I have been trying to get Rails 3 installed in Fedora, it requires Ruby to be 1.8.7 or 1.9.2. Fedora official yum repos have Ruby 1.8.6 which is of no use. So I decided to compile it myself from the source, downloaded the source, compiled it and installed it successfully.
But this weird thing happens after the install, sudo gem or sudo ruby are not working, it just returns saying command not found.
which ruby
/usr/local/bin/ruby
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
sudo ruby
sudo: ruby: command not found
sudo echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
Am I missing something, why doesnt it find ruby when its in the PATH?
check your PATH variable (set in your .bash_profile or .bashrc file, add /usr/local/bin to the front of the PATH:
PATH=/usr/local/bin:$PATH
I'd recommend that you check out RVM -- so far the best way to install and switch between different Ruby versions and to maintain Gems independently for each version!
https://rvm.io
Using RVM is much easier than compiling by hand, and it keeps all your Gems organized by Ruby version!
There's also a RailsCast on it: http://railscasts.com/episodes/200-rails-3-beta-and-rvm