I have a Rails app which i am trying to deploy in Ubuntu 18.04 LTS Linux. bundle install run ok but when I run bundle exec rake secret it shows Errno::ENOENT: No such file or directory - osascript
myappuser#ubuntu:/var/www/myapp/code$ bundle exec rake secret
rake aborted!
Errno::ENOENT: No such file or directory - osascript
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:95:in ``'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:95:in `run_applescript'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:10:in `application_exists'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole.rb:9:in `<top (required)>'
/var/www/myapp/code/config/application.rb:7:in `<top (required)>'
/var/www/myapp/code/Rakefile:5:in `require'
/var/www/myapp/code/Rakefile:5:in `<top (required)>'
/home/myappuser/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
/home/myappuser/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
Need help.
webconsole is trying to run osascript, which is macOS-specific and not available on Linux. You can replace gem 'webconsole' in your Gemfile with the following to only use it on macOS:
gem 'webconsole' if RUBY_PLATFORM.match?(/darwin/)
Related
Operating System: Ubuntu installed on a docker and a normal ubuntu installed on my personal laptop.
I am running this cron job:
*/5 * * * * /bin/bash -l -c "cd /home/deploy/railsapp && rake spec >> cron.log 2>&1"
I have tried it with bundle exec rake spec, without /bin/bash, with whenever gem, with /usr/local/bin/rake spec, but still nothing is happening except these errors.
Errors in the log file on running the cron job:
/bin/bash: bundle: command not found
/bin/bash: rake: command not found
rake aborted!
Bundler::GemNotFound: Could not find rake-11.2.2 in any of the sources
/home/deploy/railsapp/config/boot.rb:3:in `<top (required)>'
/home/deploy/railsapp/config/application.rb:1:in `<top (required)>'
/home/deploy/railsapp/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/deploy/railsapp/config/boot.rb:3:in `<top (required)>'
/home/deploy/railsapp/config/application.rb:1:in `<top (required)>'
/home/deploy/railsapp/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
bundler: failed to load command: rake (/usr/local/bin/rake)
Bundler::GemNotFound: Could not find rake-11.2.2 in any of the sources
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in `block in materialize'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `map!'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `materialize'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in `specs'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in `specs_for'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/definition.rb:174:in `requested_specs'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/environment.rb:19:in `requested_specs'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:14:in `setup'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:95:in `setup'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/setup.rb:19:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
On running rake spec manually from the command line its working fine, but from cron it is giving this error.
Any ideas ?
I am pretty sure that the issue is caused by not correctly set environment. Basically cron runs with the minimal environment so it is not aware about settings from for example .bashrc file (where you have rvm or rbenv initialization and PATH settings).
Source your environment file using . so rewrite the cron entry to something like:
*/5 * * * * /bin/bash -l -c ". /etc/environment && cd /home/deploy/railsapp && rake spec >> cron.log 2>&1"
Note that /etc/environment is just an example. You can source files like .bashrc instead.
I use whenever gem to manage crontab.
Adding
ENV.each { |k, v| env(k, v) }
to the config/schedule.rb file solved this issue for me.
Reference: https://github.com/javan/whenever/issues/656#issuecomment-239111064
Use whenever gem - this is adapter for cron, with support of rake tasks and other ruby/rails things.
Having an issue running bundle in my application, I have copied the commands and logs, and display below.
$ cd ~/Desktop/chinook/
$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Then after seeing that error I ran this command:
$ gem install rake -v 10.4.2
WARNING: You don't have /Users/kexinwu/bin in your PATH,
gem executables will not run.
Successfully installed rake-10.4.2
Parsing documentation for rake-10.4.2
Done installing documentation for rake after 1 seconds
1 gem installed
Kexins-MacBook-Pro:chinook axiner$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
$ bundle exec rake db:setup
-bash: bundle: command not found
How do I fix this error where I can run rake db:setup?
You need to install bundler, then you can use the bundle command.
gem install bundler
Try this command bundle exec
bundle exec rake db:setup
I have a problem configuring my app to user wercker. My wercker.yml looks like this:
box: ruby
services:
- postgres
build:
steps:
- script:
name: Nokogiri fix
code: bundle config build.nokogiri --use-system-libraries
- bundle-install
- rails-database-yml
- script:
name: Set up db
code: bundle exec rake db:schema:load RAILS_ENV=test
- script:
name: rspec
code: bundle exec rspec
When I run build it fails with the following error:
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace
I think that I need to install nodejs on wercker but the question is how can I do this?
As the comments on the question suggest, you need to install a javascript runtime.
You have a few options:
add gem 'therubyracer' to your Gemfile.
Install nodejs via apt-get, brew, etc.
I'd go for option 2 as to not unnecessarily add gems to your project.
I created a new model, but when I run the rake db: migrate command, it shoots me the following error:
rake aborted!
Gem::LoadError: You have already activated rake 10.4.0, but your Gemfile requires rake
10.3.2. Prepending `bundle exec` to your command may solve this.
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
What am I doing wrong?
use
bundle exec rake db:migrate
You can also update your gems by running
bundle update
Execute the below commands
a) delete your Gemfile.lock file
b)bundle install
It should update Gemfile.lock with correct rake.
OR
a) gem uninstall rake -v 10.4.0
b) gem install rake -v 10.3.2
then try running 'rake db:migrate'. it should work.
I started getting this error and would like a way to fix it:
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
I am running this from within RubyMine. I can see in my Gemfile.lock where it specifies 10.1.0. Can I just manually update my Gemfile.lock to 10.1.1?
If I do:
$gem list
....
rake (10.1.1, 10.1.0, 10.0.4, 0.9.2.2)
So I'm not sure why it isn't just working with 10.1.0?
Here's the full output from RubyMine:
/Users/jt/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jt/.rvm/gems/ruby-1.9.3-p448/bin/rake spec
Testing started at 3:15 PM ...
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/Users/jt/repos/app/config/boot.rb:6:in `<top (required)>'
/Users/jt/repos/app/config/application.rb:1:in `<top (required)>'
/Users/jt/repos/app/Rakefile:5:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
(See full trace by running task with --trace)
Process finished with exit code 1
You can remove your
Gemfile.lock file
and exec
bundle update