Running ruby project with systemd service cannot find gemfile - ruby

I would like to run a ruby project that uses bundle as a systemd service.
The project is: https://github.com/jcs/bitwarden-ruby/
I installed ruby and bundler by running sudo apt-get install ruby-full and sudo gem install bundler
In the project directory I run bundle install --deployment.
In my systemd service I have:
ExecStart=/usr/bin/env RACK_ENV=production ALLOW_SIGNUPS=1 /usr/local/bin/bundle exec rackup -p 4567 /var/lib/bitwarden/bitwarden-ruby/config.ru
Runnning this command in the terminal does work.
However when I start the service I get an error:
bash[7924]: Could not locate Gemfile or .bundle/ directory
The bundle directory is at /var/lib/bitwarden/bitwarden-ruby/.bundle.
Why can it not find it? Thanks!

Related

Fastlane doesn't work after updating to macOS Catalina [using Fishshell]

"The file '/usr/local/bin/fastlane' specified the interpreter '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby', which is not an executable command."
Managed to fix it by:
1.) sudo gem install fastlane -NV
After this, try running your fastlane commands. In my case they didn't work but the output did suggest to run the next commands:
2.) sudo gem install bundler:2.0.2
3.) bundle update --bundler
And now I'm running it using:
bundle exec fastlane your_lane
(instead of fastlane your_lane)

Bundler can't see gems installed in dockerized environment

I have a pretty basic "app" which i'm trying to dockerize using some examples found on the internet but, for some reason, it seems that bundler can't see the gems installed in my env.
Gemfile
source 'https://rubygems.org'
gem 'streamio-ffmpeg'
Dockerfile
FROM dpsxp/ffmpeg-with-ruby:2.2.1
MAINTAINER mike
RUN apt-get update && apt-get install -y \
build-essential \
cmake
ENV APP_HOME=/app
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
COPY Gemfile* ./
ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
BUNDLE_PATH=/bundle
RUN gem install bundler
RUN bundle install --jobs 20 --retry 5 --path=/bundle
COPY . ./
CMD ["rake"]
docker-compose.yml
version: '2'
services:
app:
build:
context: .
volumes:
- '.:/app'
depends_on:
- bundle
bundle:
image: busybox
volumes:
- /bundle
And now, when i'm running $ docker-compose run app gem list, the streamio-ffmpeg gem is not on the list for some reason. Also, when i'm trying to require it inside my ruby app, i'm getting LoadError: cannot load such file
Build logs: https://gist.github.com/mbajur/569b4f221cadb8a85ecc5dae8a595401
When you deal with gems by bundler, all related commands should be run with bundle exec, so in your case, it should work with below command:
docker-compose run app bundle exec gem list
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.
The command you run directly with gem list is to list the system gems, of course they are not in list.

Ruby Gems : sudo gems not showing with gems

I have a sudo rights on my ssh user. I can not run sudo bundle install command but can run bundle install without sudo.
Once I run the bundle install, Few gems get install but those who need gcc and c++ compiler I have to install in sudo permissions like sudo gem install json -v '1.8.0'.
Now if I try to run bundle that gem is not available due to installed with sudo permission.
Is there any other way to install such compiler gems without sudo?
I was not getting the right environement for installing ruby and gemsets . But
rvmsudo worked for me
I tried installing those gems which required compiler like
rvmsudo gem install json -v '1.8.0'
And it worked for me.
I am having only local user access which does not have any rights to run commands like yum

Errno::EACCES: Permission denied when installing gems via gitlab

I'm trying to setup gitlab and thus install some gems from another user account using sudo,
but I'm constantly getting Permission denied error.
sudo -u gitlab -H bundle install --deployment --without development test postgres
> Using ... ( a lot of successful gems there )
> Using pygments.rb (0.3.2) from https://github.com/gitlabhq/pygments.rb.git (at master)
> Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem
> An error occurred while installing pygments.rb (0.3.2), and Bundler cannot continue.
> Make sure that `gem install pygments.rb -v '0.3.2'` succeeds before bundling.\
sudo -u gitlab -H gem install pygments.rb -v '0.3.2'
> Successfully installed pygments.rb-0.3.2
> 1 gem installed
> Installing ri documentation for pygments.rb-0.3.2...
> Installing RDoc documentation for pygments.rb-0.3.2...
# no matter how many times I run this command, I always get the same output
# as if the gem installation doesn't stick
# I've tried to chmod
chmod 777 -R /usr/local/lib/ruby
# then Again
sudo -u gitlab -H bundle install --deployment --without development test postgres
# same result, Errno::EACCES: Permission denied - pygments.rb-0.3.2.gem
Lain suggested to try to install the bundles into another sub directory. When that worked out, it became clear the problem was about permissions in the current directory.
Executing chown -R gitlab:gitlab . has solved the problem.
In the gitlab installation guide there is a gem install command preceding our story that was ran as root and probably the gemfile or some other file had permissions change during that.
This is a permissions bug in ruby-2.0.0-p195 rvm with bundle install
are you using rvm? did you try chmod with sudo?
chmod 755 (or 777) ~/.rvm/gems/ruby-2.0.0-p195/build_info/
I did the following and got things working.
I changed the permission for the Gemfile. i.e. chmod 755 Gemfile
Then I did a sudo bundle install. This got things working and all the gems got installed. I could then start my app by rails server
Make sure your Gemfile.lock is owned by the user running the command
Although Alex's answer is correct,this worked for me as well
sudo chown -R git:git /path/to/external/volume
I'm using Digital Ocean's Gitlab Image

Why am I getting a command not found for Padrino?

EDIT: This seems to work on my CentOS machine but not my Ubuntu box.
$ which gem
/usr/bin/gem
$ which padrino
/usr/bin/padrino
$ which padrino-gen
/usr/bin/padrino-gen
I started playing with Sinatra but when I started thinking about some admin/authentication support I was lead to Padrino.
Problem is as follows.
I ran:
sudo gem install padrino
but then when I ran the create command, I got a command not found issue:
$ padrino g project demo-app
padrino: command not found
This seems to work in my directory where I created my heroku app because there's a gemfile there so I can run bundle exec before the padrino command. But shouldn't I be able to create a padrino project without a gemfile??
I faced the same issue and the following helped me out:
Simply just restarted my terminal.
If it is not feasible in your case, try to source your .bashrc/.bash_profile.
Environment managers like rbenv, rvm unfortunately require this step.
pretty strange, try with:
sudo gem install padrino-gen
If doesn't help try to directly
padrino-gen project demo-app
this worked for me in Ubuntu 11.04
# Setup Ubuntu LTS 10.4
sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo apt-get install sqlite
sudo apt-get install libsqlite3-dev
sudo apt-get install irb
sudo apt-get install rdoc
sudo apt-get install libopenssl-ruby
sudo apt-get install g++
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
>tar zxvf rubygems-1.3.6.tgz
cd rubygems-1.3.6
sudo ruby setup.rb
sudo gem1.8 install rake rspec padrino --no-ri --no-rdoc
padrino g project foo -d activerecord -b
padrino g admin
padrino rake ar:setup
ref: https://gist.github.com/1016133
I had this same problem, and fixed it by copying this command from the .bash_profile file which was created when I installed RVM, and adding it to the end of my .bashrc:
source "$HOME/.rvm/scripts/rvm"

Resources