I have a Jenkins server that pulls my build and builds it, in the shell scripts i have a fastlane command that runs by distribution. Issue is it never is able to execute sucessfully.
my shell code is simply:
bundle exec fastlane distribute_to_testflight
called as i use plugins for fastlane in my project.
Result:
$ bash -c export
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f ~/.rvm/scripts/rvm"
[App] $ bash -c " source ~/.rvm/scripts/rvm && rvm use --install --create 2.4.1 && export > rvm.env"
Using /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1
[App] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2674080270342174416.sh
+ bundle exec fastlane distribute_to_testflight
/Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find CFPropertyList-2.3.6 in any of the sources (Bundler::GemNotFound)
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/spec_set.rb:82:in `map!'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/spec_set.rb:82:in `materialize'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/definition.rb:170:in `specs'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/definition.rb:237:in `specs_for'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/definition.rb:226:in `requested_specs'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/runtime.rb:108:in `block in definition_method'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/runtime.rb:20:in `setup'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler.rb:107:in `setup'
from /Users/Shared/Jenkins/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.0/lib/bundler/setup.rb:20:in `<top (required)>'
from /Users/Shared/Jenkins/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/Shared/Jenkins/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Im not sure of the issue, i installed ruby with rvm on the jenkins user as you can see, but in my main project i work on the code with, i just have my ruby gems and files in the actual project repo that i commit to git, so perhaps i could get jenkins to use what it pulls from the repo?
Im really lost on this so any guidance on the issue would be great
I had the same issue and fixed it by calling bundle install prior to my bundle exec call:
bundle install
bundle exec fastlane distribute_to_testflight
I then use the following Fastlane command at the top of my lane so from then on it should keep things up to date:
bundle_install()
CFPropertyList-2.3.6 is a gem available in main ruby gem repo at: https://rubygems.org
So add or set in Gemfile:
source "https://rubygems.org"
then run
bundle install
and ensure your machine can go internet.
Related
I have a rails 6.1 app with an rspec test suite running on ubuntu 20.04 and i use rubymine 2022.1.3 as an IDE when i try to run the tests from the Run configuration like spec for example or when i click on the icon next to the test definition i get this error
/bin/bash -c "env RBENV_VERSION=3.0.3 /home/alex/.rbenv/libexec/rbenv exec ruby -x /var/www/project/bin/bundle exec ruby /var/www/project/bin/rails spec"
Testing started at 5:17 μ.μ. ...
rails aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/var/www/project/config/application.rb:17:in `<top (required)>'
/var/www/project/Rakefile:9:in `require'
/var/www/project/Rakefile:9:in `<top (required)>'
/var/www/project/bin/rails:4:in `require'
/var/www/project/bin/rails:4:in `<main>'
(See full trace by running task with --trace)
i get the same error when i try to run the debugger or tests with coverage and pretty much everything that goes through Run anything
/bin/bash --login -c "env RBENV_VERSION=3.0.3 /home/alex/.rbenv/libexec/rbenv exec rails g controller home"
but not
Tools > bundle > install
/bin/bash -c "env RBENV_VERSION=3.0.3 /home/alex/.rbenv/libexec/rbenv exec bundle install"
the app is running just fine locally and deployments are all fine. i even tried installing the execjs, mini_racer and libv8-node gems but i keep getting the same error
if i open another project with rails and rspec the Run configurations run just fine
i noticed that the command that rubymine uses to run the tests is slightly different on project with the working Run configurations
/bin/bash -c "env RBENV_VERSION=3.0.3 /home/alex/.rbenv/libexec/rbenv exec ruby -x /var/www/password_manager/bin/bundle exec ruby /var/www/password_manager/bin/spring rails spec"
/bin/bash -c "env RBENV_VERSION=3.0.3 /home/alex/.rbenv/libexec/rbenv exec ruby -x /var/www/project/bin/bundle exec ruby /var/www/project/bin/rails spec"
spring is not running
node version: /home/alex/.nvm/versions/node/v16.13.0/bin/node
has anyone encountered this before?
is there a way to change the command that rubymine uses?
I'm getting this one error I don't understand (I'm fairly new to rails) when using the gem 'whenever' in development mode.
What I did was update config/schedule.rb and run
whenever --update-crontab --set environment='development'
crontab -l lists:
* * * * * /bin/bash -l -c 'cd /home/vic/Desktop/WorkflowProject && bundle exec bin/rails runner -e development '\''Task.new2'\'' >> log/whenever.log 2>&1'
at config/schedule.rb
set :output, 'log/whenever.log'
every 1.minute do
runner "Task.new2"
end
at log/whenever.log
bundler: failed to load command: bin/rails (bin/rails)
Bundler::GemNotFound: Your bundle is locked to rake (11.3.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (11.3.0) has removed it. You'll need to update your bundle to a different version of rake (11.3.0) that hasn't been removed in order to install.
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:179:in `rescue in specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:173:in `specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:233:in `specs_for'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:222:in `requested_specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/runtime.rb:118:in `block in definition_method'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/runtime.rb:19:in `setup'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler.rb:99:in `setup'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/setup.rb:20:in `<top (required)>'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I would grealy appreciate the help, thank you very much!
Try the below commands.
gem install rubygems-bundler
gem regenerate_binstubs
Ref: this
Are you sure to have bundler installed? Try running bundle install inside your application directory.
If no, see Jayaprakash's answer above.
If yes, try bundle exec whenever --update-crontab --set environment='development'.
Update:
Ahh, missed that you are seeing error when your task executes.
Try this in your config/schedule.rb
env :PATH, ENV['PATH']
set :output, "#{ Whenever.path }/log/whenever.log"
every 1.minute do
runner "Task.new2"
end
I'm trying to start the rails app when Ubuntu starts up.
For this, I added these lines in /etc/rc.local.
cd /home/ubuntu/webapp/rails/passenger-ruby-rails-demo
bundle exec passenger start --port 8000 --user ubuntu --daemonize
However, the rc.local exits with error
+ cd /home/ubuntu/webapp/rails/passenger-ruby-rails-demo
+ bundle exec passenger start --port 8000 --user ubuntu --daemonize
/usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:85:in `map!'
from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:85:in `materialize'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:114:in `specs'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:159:in `specs_for'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:148:in `requested_specs'
from /usr/lib/ruby/vendor_ruby/bundler/environment.rb:18:in `requested_specs'
from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:13:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler.rb:120:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:17:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
The error is caused from using the ruby installed from rbenv; the ruby is in /home/ubuntu/.rbenv/bin/ directory. I guess when ubuntu starts up, the system ruby is executed, but it does not know anything about installed packges with rbenv's ruby and gem.
How can I solve this issue? Is there any way to make the ruby from rbenv as system's ruby?
For getting the error, I used the hints from this post: Run script with rc.local: script works, but not at boot.
EDIT
mwp's answer works fine, but I think I'd better make things clearer.
development bundle
Run bundle --deployment --binstubs to create ./vendor and copy files in bundle directory.
The setup.sh
#!/bin/bash
export APP_ROOT="/home/ubuntu/webapp/rails/passenger-ruby-rails-demo"
export APP_USER="ubuntu"
export APP_PORT="8000"
export RBENV_ROOT="/home/ubuntu/.rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
# Assuming you installed bundle with --binstubs...
$APP_ROOT/bin/passenger start --port $APP_PORT --user $APP_USER --daemonize
The rc.local file
cd /home/ubuntu/webapp/rails/passenger-ruby-rails-demo
sh ./setup.sh
exit 0
Run these commands one time:
cd /home/ubuntu/webapp/rails/passenger-ruby-rails-demo
rbenv local <the version you want>
This will create a .ruby-version file in your application directory that tells rbenv which version to use.
I would also recommend that when you deploy the application to its "production" location, you install bundler with the --deployment --binstubs flags. This will install the Gems inside a vendor subdirectory (to insulate them from an errant Gem update) and create handy shortcuts inside a bin subdirectory to run e.g. passenger, rackup, etc. without needing to do bundle exec.
However, you have another problem, and that is that rbenv (the shell function) [probably] isn't available while rc.local is running. I would recommend creating a new shell script and stashing it somewhere, possibly within your application's directory structure, with (something like) the following contents:
#!/bin/bash
export APP_ROOT="/home/ubuntu/webapp/rails/passenger-ruby-rails-demo"
export APP_USER="ubuntu"
export APP_PORT="8000"
export RBENV_ROOT="/path/to/rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
# Assuming you installed bundle with --binstubs...
"$APP_ROOT"/bin/passenger start --port $APP_PORT --user $APP_USER --daemonize
Then mark this script executable and you can call it from rc.local to start the service. As far as what you set RBENV_ROOT to, you can either use an existing user's .rbenv directory (e.g. ~ubuntu/.rbenv, assuming you installed a copy there), or you can set up a system-wide rbenv at /opt/rbenv or elsewhere. There are some good notes here.
I can think of a million different ways to improve the above script, and indeed this is only one of a million different ways to tackle this problem. Starting and stopping services is quite a hot topic in the DevOps and SysAdmin communities right now. I've had great success running Ruby applications in production using rbenv and Bundler, and if you decide to go this route, I hope you will too!
Upstart (http://upstart.ubuntu.com) can be a better way to replace rc.local.
# simple script
# http://uwsgi-docs.readthedocs.org/en/latest/Upstart.html
description "passenger "
start on runlevel [2345]
stop on runlevel [06]
respawn
# http://stackoverflow.com/questions/14823972/upstart-node-js-working-directory
script
chdir /home/ubuntu/webapp/rails/passenger-ruby-rails-demo
exec sh runme.sh
end script
Hello I have a strange problem, I'm trying to get rake task working in whenever, but have this problem Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound). It's strange, because it searches this rake version in ruby 2.1.2 version /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/spec_set.rb:92. However I'm using ruby 2.2.0 in rvm and the gem list is also using that version.
It's a simple cron job:
every 1.minute do
rake 'process_email:handle', output: 'log/mail.log', environment: 'development'
end
Rakefile:
namespace :process_email do
desc 'Handle email'
task handle: :environment do
MOBIZARD_MAILER.processor.retrieve_mail
end
end
Mobizard mailer is my own gem, that retrieves mails through ruby mail gem, that uses same ruby 2.2.0 and same gem list.
Whole stack trace in mail.log looks like this:
/home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in `map!'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in `materialize'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/definition.rb:133:in `specs'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/definition.rb:178:in `specs_for'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/definition.rb:167:in `requested_specs'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/environment.rb:18:in `requested_specs'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:13:in `setup'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler.rb:120:in `setup'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/setup.rb:17:in `<top (required)>'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/vyivrain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Thx for answering.
It is because the output is set with the -l flag, which is incorrectly interpreted by rvm.
You can read more about this issue here:
https://github.com/javan/whenever/issues/325
TL;DR
Add this to schedule.rb
ENV.each { |k, v| env(k, v) }
Ref: https://github.com/javan/whenever/issues/656
My guess is the GEM_PATH is not the same when running in a crontab and when running in your normal/dev environment. You could check it which this command
gem which rake
In my cases:
When running in crontab GEM_PATH would be something like /usr/local/lib/ruby/site_ruby/2.3.0/bundle
When running in "normal", the GEM_PATH is /usr/local/bundle
This script ENV.each { |k, v| env(k, v) } will auto add those envs to make sure ruby using the right GEM_PATH
Quote from this answer https://stackoverflow.com/a/20499839/1819549
The -l option (according to the man page) makes "bash act as if it had been invoked as a login shell". Login shells read certain initialization files from your home directory, such as .bash_profile. Since you set the value of TEST in your .bash_profile, the value you set on the command line gets overridden when bash launches.
So #Yury's answer works maybe because the command executes something in .bash_profile and I guess it update the GEM_PATH for rvm.
Has anyone seen this problem before?
When I try to run the command "heroku create", I get long error with directories related to ruby.
C:\Rails\Waterloop3>heroku create
Creating severe-samurai-489.... done
Created http://severe-samurai-489.heroku.com/ | git#heroku.com:severe-samurai-48
9.git
C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/helpers.rb:78:in ``': No such file or directory - git remote (Errno::ENOENT)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/helpe
rs.rb:78:in `block in shell'
from C:/Ruby192/lib/ruby/1.9.1/fileutils.rb:121:in `chdir'
from C:/Ruby192/lib/ruby/1.9.1/fileutils.rb:121:in `cd'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/helpe
rs.rb:78:in `shell'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/comma
nds/app.rb:265:in `create_git_remote'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/comma
nds/app.rb:49:in `create'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/comma
nd.rb:48:in `run_internal'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/comma
nd.rb:20:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/bin/heroku:13:in
`'
from C:/Ruby192/bin/heroku:19:in `load'
from C:/Ruby192/bin/heroku:19:in `<main>'
This line:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-1.14.10/lib/heroku/helpers.rb:78:in ``': No such file or directory - git remote (Errno::ENOENT)
Says that the heroku gem is try to run git and can't find it. Do you have git installed and running from the command line? It is a requirement, since it is what Heroku uses to manage deployments.