ruby-on-railsbundlerbitnamigemset

Bundle install: permission denied


Context: Trying to learn rails/ruby. used the bitnami ubuntu ruby stack VM (2.1) as development environment. its a preinstalled VM that is detailed here.

Problem: Making a new project: rails new tp Which will automatically run bundle install, which fails

Installing sqlite3 (1.3.8) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /opt/bitnami/ruby/bin/ruby extconf.rb --with-sqlite3-dir=/opt/bitnami/sqlite 
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile

make "DESTDIR="
compiling database.c
compiling backup.c
compiling sqlite3.c
compiling statement.c
compiling exception.c
linking shared-object sqlite3/sqlite3_native.so

make "DESTDIR=" install
/bin/mkdir: cannot create directory `/opt/bitnami/ruby/lib/ruby/site_ruby/2.1.0/x86_64-linux/sqlite3': Permission denied
make: *** [.RUBYARCHDIR.-.sqlite3.time] Error 1


Gem files will remain installed in /home/bitnami/.bundler/tmp/3622/gems/sqlite3-1.3.8 for inspection.
Results logged to /home/bitnami/.bundler/tmp/3622/gems/sqlite3-1.3.8/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.8), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before bundling.

Of course it fails with a permission denied because those gems are in directories managed by root and as the developer I create files and do my stuff as the regular bitnami user, of course. That includes using the rails program and using said program through an IDE. These assumptions seem clearly at odds with how the rubystack is set up or supposed to be used.

Questions:
-If my methods differ from the methods assumed by the stack, then what IS the assumed method?
-If they dont differ, why is making a new project doing administration stuff?
-How should I go about making this thing work at all?


Solution

  • Please make sure the:

    ls -l /opt/bitnami/ruby/lib/ruby/site_ruby/2.1.0/x86_64-linux/
    

    say that the folder belongs to you, not to root:root. If the rights are for user, you can't create the folder, so to fix it just do:

    sudo chown bitnami:bitnami /home/bitnami/. -R
    

    I strongly advice you to use and in order to not using the operations. Do as follows:

    1. In order to use the system ruby with just pickup it by execution:

      rvm mount /path/to/system/ruby
      
    2. Then create a gemset:

      rvm gemset create bitnami
      
    3. And use it:

      rvm gemset use bitnami
      
    4. Update or install all gems into the specified gemset, but don't use for the action, just:

      bundle install