Deploy Ubuntu 20.04 Focal Fossa Discussion
Thanks for the guide. There is an error installing NGINX on Ubuntu20.04: "The following packages have unmet dependencies:
libnginx-mod-http-passenger : Depends: passenger (= 1:6.0.4-1~bionic1) but it is not going to be installed
Depends: nginx-common (< 1.14.1) but 1.17.10-0ubuntu1 is to be installed."
Maybe you can correct the installation commands.
You are attempting to install the version of Passenger for bionic beaver, 18.04. In there "Installing NGINX & Passenger" you need to use a different repository. Use:
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger-testing focal main > /etc/apt/sources.list.d/passenger.list' instead of
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'. Also note this is still beta / testing for passenger, while it should work, the final version is expect to release in a couple more weeks.
Switch out this repository as mentioned above and rerun the commands form the installing passenger section -- this should allow you to install successfully.
I'm having an issue at the end of deployment. I get this error:
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 rake aborted!
01 URI::InvalidURIError: bad URI(is not URI?): postgresql://deploy:[email protected]/my-api-prod
Is there an issue with me using rails as API only mode? If so, I tried this according to a github issue I found:
In Capfile you add these lines (but it fails on migration after getting thru precompile) -
removed "require 'capistrano/rails'"
I'm wondering if there's some general knowledge I'm missing that's preventing me from having a successful deployment. Any tips would be greatly appreciated!
SOLVED: ok, just in case anyone else runs into this issue it's because i had special characters in my postgresql password. you can escape them or remove them.
additionally, since i was running an api i definitely had to make those changes to my capfile i listed above.
Thanks for the tutorial. Deploys to the server fine but am getting an internal server error.
The application encountered the following error: uninitialized constant ApplicationCable::ActionCable
Did you mean? ActionMailer (NameError)
Any idea why this might be happening? I haven't touched anything with ActionCable in my app and it works great on dev.
Found the answer. I'm running Rails 6 webpacker only, so I removed sprockets. My config/application.rb had 'require action_cable' commented out. Added that and came across another issue.
cap's deploy:assets:backup_manifest was failing because it couldn't find the assets manifest file. Since I removed sprockets it doesn't exist.
I added Rake::Task["deploy:assets:backup_manifest"].clear_actions to my config/deploy.rb and now everything works. Going to do some research to make sure I didn't stop doing something I need by calling that. Its working for now
Thanks for the tutorial. I've been trying for a while to fiture out how to setup a server to deploy rails apps. I followed the video and everything went well but when I try to deploy I get the following error: I have search all over and posted on stackoverflow.com but can't get any answer. Any help would be greatly appreciated. I will say that I did use ubuntu 20, so if that is the issue I am willing to scrp the whole thig and do it again using 18.4 instead.
terminated with exception (report_on_exception is true):
Traceback (most recent call last):
25: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:12:in
block (2 levels) in execute'run'
24: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:31:in
23: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:31:in
instance_exec'block (3 levels) in '
22: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/capistrano-rbenv-2.2.0/lib/capistrano/tasks/rbenv.rake:10:in
21: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:61:in
20: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in
19: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in
tap'block in create_command_and_execute'
18: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in
17: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/netssh.rb:130:in
16: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/netssh.rb:177:in
15: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/connection_pool.rb:63:in
14: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/connection_pool.rb:63:in
13: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh.rb:255:in
12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/session.rb:72:in
11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/session.rb:72:in
each'block in authenticate'
10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/session.rb:86:in
9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/methods/publickey.rb:19:in
8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/key_manager.rb:111:in
7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/key_manager.rb:250:in
6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/key_manager.rb:250:in
5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/key_manager.rb:254:in
block in load_identities'load_public_key'
4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/key_factory.rb:84:in
3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/key_factory.rb:103:in
2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/buffer.rb:248:in
1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/buffer.rb:322:in
read_keyblob'raiseUnlessLoaded': unsupported key type `ssh-ed25519' (NotImplementedError)
net-ssh requires the following gems for ed25519 support:
- ed25519 (>= 1.2, < 2.0)
- bcrypt_pbkdf (>= 1.0, < 2.0) See https://github.com/net-ssh/net-ssh/issues/565 for more information LoadError : "cannot load such file -- bcrypt_pbkdf_ext" (Backtrace restricted to imported tasks) cap aborted! NotImplementedError: unsupported key type `ssh-ed25519' net-ssh requires the following gems for ed25519 support:
- ed25519 (>= 1.2, < 2.0)
- bcrypt_pbkdf (>= 1.0, < 2.0) See https://github.com/net-ssh/net-ssh/issues/565 for more information LoadError : "cannot load such file -- bcrypt_pbkdf_ext"
Tasks: TOP => rbenv:validate
Check this StackOverflow > https://stackoverflow.com/questions/57968022/capistrano-deployment-error-in-rails-application
On MacOS, you'll need to add your SSH Key after every system restart (ssh-add)
Beautiful. Thanks for the guide. Got my production environment setup and running in no time!
Other than not being able to use the Capistrano commands as listed, needed to use bundle exec, this was all straight forward. How long is it supposed to sit on bundler:install when using Capistrano to deploy? It isn't crashing, I'm not getting any error messages, but it's been over 45 minutes. If I ssh into the server from a different terminal window, I can see processes working, but I can't differentiate which process is running the bundler:install.
Notes on this guide
1 : the section for deployment, where you mention the block to edit, it ought to be stated that it should follow the line install_plugin Capistrano::SCM::Git otherwise bad ordering will make the
cap commands fail.
2: I would suggest on the
capfile configuration comment to include all files that you need to avoid being committed via gitignore (assuming not using environment variables), [often initializer] files with keys to things like s3, e-commerce, devise ...
*deployment hangs RAILS_ENV=development on assets precompile Rails 220.127.116.11 *
INFO [7e60e5e4] Running $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as [email protected] DEBUG [7e60e5e4] Command: cd /home/deploy/zappa/releases/20210110095959 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.1" RAILS_ENV="development" RAILS_GROUPS="" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile ) DEBUG [7e60e5e4] error Couldn't find an integrity file DEBUG [7e60e5e4] error Found 1 errors. DEBUG [7e60e5e4] ======================================== Your Yarn packages are out of date! Please run `yarn install --check-files` to update. ======================================== To disable this check, please change `check_yarn_integrity` to `false` in your webpacker config file (config/webpacker.yml).
yarn install --check-files either locally or in the file server does not change behaviour one iota (on the server it is pointless as the next deployment creates a new directory). Setting 'check_yarn_integrity' to false does not change the behaviour.
Now I have read that should be in the shared directory (append :linked_dirs,
node_modules) which make sense given the two directories can be a 200 MB bloat. Tried that... no happiness.
The github repositry states:
ensure that the installed packages match the yarn.lock file. ; the VPS yarn.lock file is empty. Another assumption I have been working on is the environment; it could be that development mode
yarn install --check-files did finally populate the shared directory ([ahem] after I had polluted all sorts of other directories. That moved the process further... to another error.
LoadError: Could not load the 'listen' gem. Addgem 'listen'
to the development group of your Gemfile
buuut... that was already loaded.
Error identical to running Running
RAILS_ENV=development bundle install; but this returns a clue:
Gems in the groups development and test were not installed.
SO and rails repo (https://github.com/rails/rails/issues/24063) comments of moving the gem from the development block to the global block .
RAILS_ENV=development bundle install can now run (you'll see the various modules taking their time to compile (hundreds of MBs worth). Deployment can proceed.
1 - ensure
append :linked_dirs, 'node_modules', 'public/packs'
2 - if in dev mode, move
listento general block.
3 - Run
RAILS_ENV=development bundle install on server to feel safe.
Then question if you need the other dev block gems on the server and move those to the global block.
OK. I am not aware of how to install those deve/test gems remotely. Any suggestion is welcome.
This guide is excellent. But I still do not understand why I got into 503 error when I removed /etc/nginx/site-enabled/default file (chapter 3). I restored it and nginx works fine.
Thanks a lot for this excellent guide :-) Everything works fine except i would like to use rails console on the deploy machine, and i constantly get this error message : "Your Ruby version is 2.7.0, but your Gemfile specified 3.0.0".
When i "ruby -v" with the deploy user, i get "3.0.0" but when i "ruby -v" with root, i get "2.7.0"...
Does anyone have an idea where it could come from ?
When I have problems writing an essay, I find an assistant for writing academic papers on this essay writing service https://clubessay.com/essay-help . Only professionals work here and I really like the fact that I can be sure of the quality of the written text.