Reputation: 23548
When I run bundle install
on my AWS instance, I get this syntax error on my gemfile:
Gemfile syntax error:
/var/www/mheesen.cc/releases/20131206072125/Gemfile:18: syntax error,
unexpected ':', expecting kEND
...tter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-r...
^
This is an error typically associated with me having Ruby 1.8 installed, but by typing ruby -v
I get ruby 1.9.3
.
Digging a little further, I read "error in your Gemfile, and Bundler cannot continue", and figured that it could be because my bundler is using a system Ruby rather than a local one. (I'm not exactly sure how that works, but oh well.)
I thought the best remedy was to uninstall the bundler
gem and reinstall it and hopefully it will pick up the right bundler with the right Ruby version but trying to uninstall on my project directory gives me this error:
path/to/my/project$ gem uninstall bundler
ERROR: While executing gem ... (Gem::InstallError)
bundler is not installed in GEM_HOME, try:
gem uninstall -i /usr/local/rvm/gems/ruby-1.9.3-p484@global bundler
This confirms my suspicion that it's using a system-wide bundler, but then trying to uninstall that system-wide bundler gives me a permission error:
gem uninstall -i /usr/local/rvm/gems/ruby-1.9.3-p484@global bundler
Remove executables:
bundle
in addition to the gem? [Yn] Y
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the
/usr/local/rvm/gems/ruby-1.9.3-p484@global/bin directory.
I tried changing the permissions on the said folder.. didn't have the permissions to do that either.
Trying to update bundler on my project also tells me that everything is up to date.
What do I do now? What are my options? I'm running out of ideas.
Upvotes: 1
Views: 1104
Reputation: 23548
although the answer got correctly answered.. I'll put down some notes just for my own reference (and hopefully it can be useful for others).. I'll explain with an example:
suppose we would like to kill the thin
server running on our AWS.. to do that we:
ps aux | grep thin
sudo kill -9 pid
rvmsudo thin start -p 80 -d
-p
is to chose port number, -d
is to run as a daemonnotice how we are using rvmsudo
rather than just rvm
(note, this is specific to rvm.. don't go around thinking you can just stick sudo to any random command) and that's because as mentioned above there are two kinds of gems:
when you type sudo install gem or sudo gem do something, sudo
puts you in the system environment, thus you are using system wide gems.
likewise.. if you just install a gem without sudo then u're just installing a local gem. That being said.. you may still want local gems to perform actions that require root permission.. that's when rvmsudo comes into play and you do something like rvmsudo thin start ..
.. you are using a local gem but while having root permissions.
Upvotes: 2
Reputation: 16722
Quick fix:
$ cd /var/www/mheesen.cc/releases/20131206072125
$ sudo gem install bundler # Since "bundler is not installed in GEM_HOME"
$ sudo bundle install
Long fix:
It seems you have RVM installed as a system package, probably through sudo apt-get install rvm
. If possible uninstall that and install it using RVM install guide. Do not install using sudo
.
Steps:
# Uninstall system package RVM (in flavor of RVM user install method)
$ sudo apt-get remove rvm
# Don't edit your bashrc. RVM alone will attempt to setup your shell (2013)
$ \curl -sSL https://get.rvm.io | bash
$ source ~/.rvm/scripts/rvm
$ rvm requirements #=> will install gawk, g++, libreadline6-dev, etc...
$ rvm install 1.9.3
$ rvm use --default 2.0.0
You should enforce the ruby version to use within a .ruby-version
file within your project's directory (commit this changes and deploy again) with this content:
$ vim .ruby-version
1.9.3
As a bonus you can completely replace old system ruby 1.8.7 with latest and greatest:
# Use this to replace old 1.8.7 on your system
$ git clone https://github.com/sstephenson/ruby-build.git
$ cd ruby-build
$ ./install.sh
$ ruby-build 2.0.0-p353 /usr/local
Notes on GEM_HOME and related:
GEM_PATH provides the locations (there may be several) where gems can be found
GEM_HOME is where gems will be installed (by default)
Therefore GEM_PATH should include GEM_HOME
Upvotes: 2