Problems installing Rails on Heroku

Newbie here. I’m having difficulty installing Rails on Heroku following the instructions at https://devcenter.heroku.com/articles/getting-started-with-ruby#introduction. I’ve installed Rails on my Mac, but when I try to install Bundler per the initial step, I get the following:

WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren’t both writable.
WARNING: You don’t have /Users/nicolefreed/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing bundler:
bundler requires RubyGems version >= 1.3.6

I’ve just installed the proper version of Rails (twice, actually) for my OS, which is 10.6.8 (don’t ask why I’m using an older system, and no, I can’t update at this time :slight_smile: ), so I don’t understand why the Bundler installer is telling me I don’t have the proper components in the proper places, when I’ve supposedly just installed them?

It seems you are using the system Ruby that ships with OS X and that is installed outside of your user directory.

So you can:

  • Install gems system wide by doing sudo gem install gemname, or
  • Add the bin directory to your PATH by doing this in ~/.bash_profile PATH=$PATH:/Users/nicolefreed/.gem/ruby/1.8/bin export PATH

After that, you need to update RubyGems, as per this message:

bundler requires RubyGems version >= 1.3.6

Reference:

1 Like

Thanks. Where do I find the names of the gems I need to install? I’m new to all this.

Also, I see no such directory or file as .bash_profile. What now?

Not sure what you mean.

I don’t have a MAC, but on Linux, the .bash_profile equivalent (.bashrc for me) is a hidden file in your home directory.

I tried the command sudo gem install gemname literally, and got ERROR: could not find gem gemname locally or in a repository, so I assume “gemname” refers to the actual names of the gems (are these libraries?) I need to install. I have no idea which ones I’m supposed to install, so I asked for a list.

How do I search for hidden files? I’ve tried listing the contents of my home directory, and again, no such file.

Upgrading your OS to the latest is always the first step, why can’t you upgrade?

bundler is the gem you mentioned you were trying to install/use.
Bundler runs through a file named ‘Gemfile’ in the root of your rails projects and installs all the gems(libraries) listed there.

sudo gem install bundler
bundle install

But before you do any of that you may as well get a new version of Ruby installed so you’re up to date. Install rbenv to manage Ruby installations https://github.com/sstephenson/rbenv and ruby 2.1.3(that latest version currently supported by Heroku)
The rbenv Readme has info you should read about how PATH works.

1 Like

bundler is the gem you mentioned you were trying to install/use.
Bundler runs through a file named ‘Gemfile’ in the root of your rails projects
and installs all the gems(libraries) listed there.

Oh, I see. Thanks.

But before you do any of that you may as well get a new version of Ruby installed so you’re up to date. Install rbenv to manage Ruby installations https://github.com/sstephenson/rbenv and ruby 2.1.3(that latest version currently supported by Heroku)
The rbenv Readme has info you should read about how PATH works.

Okey-doke. Let’s see how this goes…

Anyone know if the Python/Django install on Heroku is any easier? I could probably use Django just as easily for what I want to do, and it might be less of a headache.

So I’ve installed rbenv and ruby-build using Homebrew, per Stephenson’s instructions for Mac OSX. However, there’s a bit at the end that I don’t understand:

Afterwards you’ll still need to add eval "$(rbenv init -)" to your profile as stated in the caveats. You’ll only ever have to do this once.

I’ve found information online on creating editing the .bash_profile, but I’m not sure exactly what to do with it. Do I simply create/open a new .bash_profile file, copy and paste the above command, and then save it?

Never mind. One of the commands in the Git install instructions did the trick. :slight_smile:

So, @markbrown4 and @James_Hibbard , I’ve installed rbenv and ruby-build using Homebrew, and added the eval “$(rbenv init -)” and PATH commands to my .bash_profile, but I still get the error message

ERROR:  Error installing bundler:
    bundler requires RubyGems version >= 1.3.6

when I try to install bundler. What am I missing?

So checklist time :smile:

  • You have installed rbenv
  • You have installed ruby-build
  • Updated your .bash_profile to include the rbenv init line eval "$(rbenv init -)"
  • You have installed a version of ruby using rbenv
  • You have set that version to global
  • You have updated bundler
  • After installing any gems you have run rbenv rehash

I haven’t set the version of Ruby to global (no idea how to do this), updated bundler (haven’t been able to install it, per the error message above), or run rbenv rehash (no idea how to do this). I have no idea what I’m doing; I’ve just been following the instructions in the heroku install, as well as the instructions of folks here when I run into errors or problems. Please advise next steps.

Update RubyGems, install bundler

sudo gem update --system
sudo gem install bundler

If you haven’t ever tried Rails or Django you shouldn’t expect to be able to deploy them to Heroku. There’s always a little bit of work getting a development environment setup the first time and each stack it’s own quirks. Maybe you should just be thinking of getting your app working locally before worrying about deploying it to Heroku.

Read the rbenv readme to understand what it’s doing, here’s a cheat sheet where “<version>” is a ruby version number like “1.9.3-p392”

# install/uninstall a Ruby version
rbenv install <version>
rbenv uninstall <version>

# list all/current Ruby versions
rbenv versions
rbenv version

# set a version of Ruby to use globally/local to a directory
rbenv global <version>
rbenv local <version>

# reload executable commands after an install like rails or bundle
rbenv rehash
1 Like

Sigh. I was really hoping this would be like installing WordPress. Apparently not. However, getting “my” app working locally would defeat the purpose of this exercise, which is to deploy New Relic in a hosted open-source app so I can get a free Learnable subscription. So I don’t really have a choice here, unless I want to turn my Mac into a web server, which I understand is a whole heck of a lot more complex than this. :slight_smile:

Also, I’m seeing cautions not use sudo with rbenv. What are alternative commands within rbenv?

Ha! I seem to have missed a whole set of post-install commands at http://guides.railsgirls.com/install/#setup-for-os-x. Looks like these are taking care of the gem install and bundler install problems. Yay!

1 Like