We used to have a redmine setup on an Ubuntu 12 based server but our hoster upgraded the servers and we now have to move everything to the new machine. It now runs under Ubuntu 14LTS. I've installed the LAMP package with apt as well as the redmine one and (I assume) all dependencies required (including Passenger).
I did the modifications on the Apache2 conf files and I'm now able to access the redmine site... only to get the error page showing the following:
Bundler::PermissionError (Bundler::PermissionError)
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/shared_helpers.rb:110:in `rescue in filesystem_access'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/shared_helpers.rb:108:in `filesystem_access'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/definition.rb:306:in `lock'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/runtime.rb:122:in `lock'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/runtime.rb:49:in `setup'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler.rb:101:in `setup'
/var/lib/gems/1.9.1/gems/bundler-1.15.3/lib/bundler/setup.rb:19:in `<top (required)>'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:245:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:348:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:243:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'
Application root
/usr/share/redmine
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
production
Ruby interpreter command
/usr/bin/ruby
User and groups
uid=33(www-data) gid=33(www-data) groups=33(www-data)
All the information I can get from googling relate to a manual install of Ruby using RVM or RBENV, but I did the setup through apt (and, yes, using sudo apt-get... which I now know is not good for bundler).
I know the following are installed:
redmine 2.4.2-1 (from apt)
ruby 1.9.3 (ruby -v) but it looks like gems are running with/from 1.9.1
rails 3.2.16 (rails -v)
passenger 4.0.37-2
I've tried changing chown www-data /var/lib/gems/1.9.1/gems/bundler-1.15.3 but no success.
Is there a way to correct this or should I trash all the setup and restart manually without apt?
From the stacktrace above this looks like the section of bundler responsible for creating a Gemfile.lock in the application root directory.
https://github.com/bundler/bundler/blob/1-15-stable/lib/bundler/definition.rb#L307
the uid and gid of your passenger process appear to be www-data - does this user have write access to /usr/share/redmine? If not, that is likely what is wrong here - your passenger process is trying to generate a Gemfile.lock but does not have permission to do so.
This is a tutorial on linux users and groups - it should give you an overview of why the above issue is occurring.
A fix would be to add www-data to the group that owns /usr/share/redmine, and then grant group-level write access recursively to that group.
Related
What must I do when I want to copy an installed gem from one installation to another one without using the gem command?
I have to install SQLite3 on a server without an internet connection. Normally I can do it with a copy of the gem-file:
gem install --local sqlite3-1.4.0.gem --platform ruby
But for SQLite3 it needs a connection to the internet to get libraries to compile some binaries. The installation worked well on a computer with an internet connection.
So my idea was to take my successful installation on the same OS and same Ruby version and copy all the related components, but this did not work.
When I called:
require 'sequel'
db = Sequel.sqlite
I got this error:
LoadError: The specified module could not be found
d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so
(Sequel::AdapterNotFound)
In the trace is:
d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': LoadError: 126: The specified module could not be found. - d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so (Sequel::AdapterNotFound)
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:2:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/adapters/sqlite.rb:3:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:88:in `load_adapter'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:17:in `adapter_class'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:45:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:121:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:399:in `adapter_method'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:406:in `block (2 levels) in def_adapter_method'
from _ruby_version.rb:21:in `<main>'
but the file exists:
What is my error?
I'm using Windows Server 2016.
I found a precompiled version of SQLite3 in a GitHub issue which works for me, but I would like to use a newer version.
Use Bundler for this.
In short:
Run gem install bundler on each machine you're using.
Maintain a project Gemfile listing all requirements
Run bundle install when your Gemfile changes and bundle update to update to latest versions. This will generate the Gemfile.lock file.
Prefix ruby execution with bundle exec, e.g. bundle exec ruby myscript or bundle exec rails c
That's a brief summary, but please read up more on Bundler. It's an essential part of modern Ruby deployment.
You need to use the package option of bundler.
First you need to cache your dependencies into vendor/cache with:
bundle package --all --all-platforms
This will install all the dependencies of your Gemfile locally, then add the directory to your source code repository.
When deploying make sure you use bundle install --local to use the local version.
See the documentation for bundle package for more information.
I recently switched from Linux to Mac, and while trying to run bundle on one of my previous projects, I get the error below:
System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:959:in `read': Permission denied - /Library/Ruby/Gems/2.0.0/specifications/puma-2.14.0.gemspec (Errno::EACCES)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:959:in `load'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:644:in `block (2 levels) in each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `block in each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:658:in `each_normal'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:669:in `_all'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:822:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:253:in `find_all'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:253:in `matching_specs'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:277:in `to_specs'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/bundle:22:in `<main>'
I have tried reinstalling bundler, rbenv and ruby, but I keep getting the same error. I ran the command with sudo and it works, how can I set the permission without having to use sudo
I retried with sudo now and it works. How can U make it work without sudo
To make bundler work without sudo, you should install all your gem dependencies in a local user directory (this is the recommended way)
bundle install --path vendor/bundle
Now when you run your program, bundle will find all your libraries in the new location
bundle exec ruby app.rb
If you are using git, make sure to add vendor to your .gitignore to avoid having all your gem libraries in your "new files" list.
I am using RVM on my server to manage ruby. I have a gem that is a daemon that I want to run as an unprivileged user, however, when I attempt to do so, I get a permissions error:
statusbot#host config]$ statusbot run
fatal: Not a git repository (or any of the parent directories): .git
/usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/definition.rb:235:in `rescue in lock': There was an error while trying to write to Gemfile.lock. It is likely that (Bundler::InstallError)
you need to allow write permissions for the file at path:
/usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/definition.rb:220:in `lock'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/environment.rb:34:in `lock'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler/runtime.rb:43:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/bundler-1.3.2/lib/bundler.rb:120:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/rubygems-bundler-1.1.1/lib/rubygems-bundler/noexec.rb:79:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/rubygems-bundler-1.1.1/lib/rubygems-bundler/noexec.rb:91:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:9:in `<main>'
Likewise, I am unable to install gems on a per-user basis:
[statusbot#host ~]$ gem install ~/StatusBot-0.0.5.gem
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.5
Using RVM in multi user mode requires:
RVM is installed using sudo not root user.
All users wanting to install rubies / gems must be in the group rvm (an extra use case is OSX wher even you are in rvm group when checked with id1 - it could be still not effective for the shell and restart is needed)
The extra use case is mixed mode where only parts of RVM are in system and user can create gemsets in $HOME, read more about it at RVM site: https://rvm.io/rvm/install
It looks like a problem with a gem, according to https://stackoverflow.com/a/4151540/497756 and the followed article http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/ from one of bundler authors Gemfile.lock should not be part of the gem.
Try:
sudo rm -f /usr/local/rvm/gems/ruby-1.9.3-p374/gems/StatusBot-0.0.4/Gemfile.lock
I have installed Ruby v1.9.2, and (according to the instructions on http://rubyonrails.org/download) I am trying to install Gems. I've downloaded the 1.4.2 zip from http://rubyforge.org/frs/?group_id=126, but when I run setup.rb, I get the following error/trace:
C:\temp\rubygemsInstall\rubygems-1.4.2\rubygems-1.4.2>setup.rb
C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/source_index.
rb:62:in `installed_spec_directories': undefined method `path' for Gem:Module (N
oMethodError)
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
source_index.rb:52:in `from_installed_gems'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:914:in `source_index'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:83:in `init_gemspecs'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:13:in `initialize'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `new'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `searcher'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:495:in `find_files'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:1034:in `load_plugins'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_runner.rb:84:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/setup.rb:25:i
n `<main>'
I am running Windows Server 2008 R2 - please post a comment if there is any other relevant info.
How do I get around this error?
The windows RubyInstaller includes rubygems already, so you don't have to install it separately. I'm assuming you're using RubyInstaller because that's what the rubyonrails.org page links you to if you click on the Windows link, but there is more information on the RubyInstaller page in the Help section.
What happens if you go to a cmd prompt and do "gem list"?
Older versions of rubygems aren't completely compatible with Ruby 1.9.2. I realize the OP discovered that rubygems was already installed, but for those who still need to install it, all you need to do is downgrade to Ruby 1.8.7 and then it should work properly. This is where a tool like RVM really comes in handy.
I have what looks like multiple versions of rubygems installed on my machine, when i gem list i see all my gems, but when i go to run scripts, i get error messages like
Missing these required gems:
SystemTimer
Is there any methodology I can follow to remove all versions of rubygems but one? Ideally i would like to be able to access all the gems that show up under gem list in my programs.
From Gem Environment
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Still if i run:
$ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby script/mailer_daemon_fetcher start production
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:164:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:169:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
Missing these required gems:
SystemTimer
You're running:
ruby 1.8.7.72 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
rubygems 1.3.5 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8, /Library/Ruby/Gems/1.8
note in the above i'm manually calling ruby**/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby** this is the same file that my /usr/bin/ruby is symlinked to, and also my GEM_PATH is set to be /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
full output of gem environment is available here: http://pastie.org/661104
I think the problem is SystemTimer loads slightly oddly so you need more configuration in environment.rb
The "problem" seems to be that gem is called "SystemTimer" but you need to load "system_timer". In order to accomplish this with environment.rb you should use:
config.gem 'SystemTimer', :lib => 'system_timer'
That seemed to solve the same problem for me.
I have a feeling that you might be using a different version of ruby than ruby gems is. Either that or ruby doesn't know where to look for your gems.
See the the gem installation guide to ensure your environment is configured to use gems.
If you're still having problems after following instructions, ensure that you haven't got multiple versions of ruby installed. In the event that there are multiple version of Ruby available, make sure your scripts are calling the same version of Ruby as gem is. This is done by comparing the gem environment listing for RUBY_EXECUTABLE against your scripts' shebang line. Double check to follow any symlinks, because most distribution based installations of ruby will symlink /usr/bin/ruby to /usr/bin/ruby1.8
You should also check that your gems were installed by the same user who is running the script.
If you ran gem install without root privileges the new gems will be installed in your home directory. If you're running a script that depends on these gems as another user. Those installed gems will not be found. However, there's no problems if your gems are installed by root and a different user is running scripts that requires those gems.
I experienced this problem while switching from Ruby to Ruby Enterprise Edition. I found that I had to install all my required gems again using REE's instance of gem.
gem cleanup
it will delete all old gem versions
you have problems with environment - running gem gets others than when you use rubygems in script
look at output of (especially GEM PATHS)
gem environment
also you can compare results of ruby -e 'p ENV' executed in shell and p ENV execute somewhere in your code — look for differences in gem related stuff
Using RVM https://rvm.io/ you can have different versions of Ruby (Enterprise Edition, MRI, Rubinius, etc) and different gem sets.
Check it out, it is really useful !