How to Start Ruby 1.9 Without Rubygems

how do you start ruby 1.9 without rubygems

ruby --disable-gems

is the MRI (1.9) commandline parameter. "It prevents the addition of gem installation directories to the default load path". (The Ruby Programming Language, p. 391)

Edit 25-10-2012: Ruby core had the same idea as @rogerdpack in the comments and added the more verbose ruby --help parameter. Ruby revision!

Is there a way to call ruby1.9 without loading rubygems?

Yes, you can use the --disable-gems option.

Note that whether or not passing options in the shebang line works depends on your operating system. Some operating systems don't support passing options at all, some only support passing one option or argument.

So, if you have for example

#!/usr/bin/env ruby

Then it's pretty unlikely that you will be able to attach the option to the end. If OTOH you change that to

#!/usr/local/bin/ruby --disable-gems

Then you have hardwired the location of the Ruby binary into your script.

And of course there are operating systems that don't interpret shebang lines at all. (After all, they were never specified in any standard, and aren't even properly documented.)

An alternative would be to set the RUBYOPT environment variable in your shell environment and simply switch to a different environment with RUBYOPT unset (or set to -w, my personal favorite) for your Ruby development.

Installing Gems without rvm, as root, with explicit version of ruby

I had the same issue (linecache19 hangs forever/indefinitely) when using rbenv on OS X Lion. I found the solution was to install Ruby with OpenSSL option, like this:

rbenv install 1.9.2-p290 --with-openssl-dir=/usr/local
rbenv rehash
rbenv global 1.9.2-p290

Now, you can run or bundle this and it'll install fine:

gem install ruby-debug19

Hope that helps someone.

Ruby: How to install a specific version of a ruby gem?

Use the -v flag:

$ gem install fog -v 1.8

Ruby gems not being loaded

Thanks very much to Josh and grenierm5 for their time and advice - RBENV was a great help, definitely makes life easier.

The answer is two-part: RBENV to solve my weird environment issues, but then also to solve the mysql gem install issue, I had to install the following Debian packages:

apt-get install mysql-client libmysqlclient-dev

This was answered here: ERROR: Failed to build gem native extension (mysql2 on rails 3.2.3)

Not able to include 'git' gem in ruby Gemfile

It looks like you manually crafted the Gemfile.lock file. This is usually never needed, as that file is generated by bundle automatically. It essentially contains the exact version numbers that bundler has downloaded for you.

Bundle, when running in deployment mode (--deployment) will check both of your files, and will refuse to run, if there are any mismatches between them, or if the Gemfile.lock file would need any updates. This is done as a sanity check, as those files should be made in sync while development, and not during production.

Try to remove Gemfile.lock, and start over. Since the version numbers you need to use are already present inside your Gemfile, it should make a proper Gemfile.lock without any issues. Also at first do not run it in --deployment mode, as that one will not generate a Gemfile.lock file.

All of these steps are actually noted in the error message you re receiving from bundler:

You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

Note that the Gemfile.lock file that is generated afterwards is still important (it contains the exact versions you are using), and should be part of your repository.

Also an additional problem you might encounter is that you are still using ruby 1.9, so you also have to fix the pg gem version inside your Gemfile like so:

source 'https://rubygems.org'
gem 'pg', '~> 0.18.4'
gem 'git', '~> 1.3'

the resulting Gemfile.lock will be something like this:

GEM
remote: https://rubygems.org/
specs:
git (1.3.0)
pg (0.18.4)

PLATFORMS
ruby

DEPENDENCIES
git (~> 1.3)
pg (~> 0.18.4)


Related Topics



Leave a reply



Submit