Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy issue: "bundler: command not found: capistrano" despite "bundle install" clearing without errors? #4089

Closed
GlassedSilver opened this issue Jun 6, 2019 · 17 comments

Comments

@GlassedSilver
Copy link
Contributor

I checked if the capistrano version is correct, it is. bundle info capistrano returns version 3.11.0.

I'm a bit baffled, I must be missing something here that must be self-explanatory to someone half-way experienced with ruby/capistrano. The install script only mentions the one like

bundle exec capistrano production deploy

But that's where the fun stops for me:

bundler: command not found: capistrano
Install missing gem executables with 'bundle install'

Other than that I have since finished the part on my server. (trying to deploy from a separate VM that also runs Ubuntu 18.04. Server edition for the danbooru VM and Desktop for the deployment VM)

Sorry if the question is super silly. I did try googling and asking in another place, but maybe that's a project-specific issue? Not sure. (googling the error in brackets returns only three results and they are... sketchy.....)

@r888888888
Copy link
Collaborator

You can try bin/bundle exec production deploy.

@GlassedSilver
Copy link
Contributor Author

GlassedSilver commented Jun 6, 2019

Nope, no good. :( (same error)

@kdoshere
Copy link

kdoshere commented Jun 6, 2019

@GlassedSilver
try:

cd ~/danbooru
bundle install
yarn install
RAILS_ENV=production bundle exec rake db:migrate
bundle exec cap production deploy

work for me

@GlassedSilver
Copy link
Contributor Author

GlassedSilver commented Jun 7, 2019

@GlassedSilver
try:

cd ~/danbooru
bundle install
yarn install
RAILS_ENV=production bundle exec rake db:migrate
bundle exec cap production deploy

work for me

Hmm... just so we're clear... I run these command on my deployment VM, right?

Anyhow, that's what I did and when I issued "yarn install" the terminal returned:

00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'install'

~/danbooru being my project folder all there is inside of it is the INSTALL.debian script.

What kind of system are you using and do you have a list of dependencies you installed? Because I noticed that a fresh Ubuntu 18.04 needed a lot of packages added. Not that that's a bad thing in itself, it was mostly just a nuissance to run, inspect error, find dependency, install dependency, run again, rinse and repeat the same process over and over again. I eventually wrote down whatever it wanted me to install so should I try with a completely new installation I wouldn't need to figure out everything all over again. :D Also I could add contribute to documentation if desired. Wouldn't mind at all to replay the process once I'm comfortable and help others too step by step. :)

Update: Solved the issue with yarn, proceeding with the rest for now. Basically Ubuntu's repo has an ANCIENT version of yarn. I mean... it's REALLY old. 0.2 or something. yarnpkg/yarn#3708 (comment) solved it. (and the comment pradt refers to)

Spits a bunch of warnings though... (will update with what it says a little later)

Update 2: These are the warnings I'm getting when I yarn install. (yarn version 1.16.0)

~/danbooru$ yarn install
yarn install v1.16.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.7: The platform "linux" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > expose-loader@0.7.5" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > rails-erb-loader@5.4.2" has unmet peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
warning " > webpack-cli@3.0.8" has unmet peer dependency "webpack@^4.x.x".
warning " > eslint-loader@2.1.0" has unmet peer dependency "webpack@>=2.0.0 <5.0.0".
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
[4/4] Building fresh packages...
Done in 67.14s.

@kdoshere
Copy link

kdoshere commented Jun 7, 2019

@GlassedSilver

Well a little install script to ease your life (tested in Ubuntu Server 18.04).

You can get it here: http://puu.sh/DD1We/650c540098.sh

Once the script is done and you logged in with the new user you can go ahead and do the following:

Move the files from:
script/install/danbooru_local_config.rb.templ
script/install/database.yml.templ

to:

danbooru/config/danbooru_local_config.rb
danbooru/config/database.yml

After that:

cd ~/danbooru
bundle install
yarn install
RAILS_ENV=production bundle exec rake db:migrate
bundle exec cap production deploy

If during the bundle install you get a warning like "can't find gem bundler" it can be fixed by doing either:

a) gem install bundler -v 1.16.1
or
b) gem update --system and bundle install

After that you'll have to modify the script according to your setup and needs.
You can also use "bundle exec rails server" to run it without doing a deploy but I have never used it that way.

And regarding the warnings I don't know too much about that, hopefully someone else will answer it.

@GlassedSilver
Copy link
Contributor Author

@GlassedSilver

Well a little install script to ease your life (tested in Ubuntu Server 18.04).

You can get it here: http://puu.sh/DD1We/650c540098.sh

Once the script is done and you logged in with the new user you can go ahead and do the following:

Move the files from:
script/install/danbooru_local_config.rb.templ
script/install/database.yml.templ

to:

danbooru/config/danbooru_local_config.rb
danbooru/config/database.yml

After that:

cd ~/danbooru
bundle install
yarn install
RAILS_ENV=production bundle exec rake db:migrate
bundle exec cap production deploy

If during the bundle install you get a warning like "can't find gem bundler" it can be fixed by doing either:

a) gem install bundler -v 1.16.1
or
b) gem update --system and bundle install

After that you'll have to modify the script according to your setup and needs.
You can also use "bundle exec rails server" to run it without doing a deploy but I have never used it that way.

And regarding the warnings I don't know too much about that, hopefully someone else will answer it.

Wow, thank you! I'll try it out soon, no sure if I still get to it tonight, because I'll be leaving for an anime convention in a few hours (how fitting... :P) but that's definitely something I'll be looking forward to if I can't get it done by the time I head off. Again, thank you so very much.

As for the system you tested it on: am I right to assume you deploy and run everything on the same machine here? I thought it was advised to deploy from a machine other than what the server is running on? At least the man himself said so in 2015. :)

@kdoshere
Copy link

kdoshere commented Jun 8, 2019

Nah, Im using Windows 10, remotely connected to my Ubuntu server VM where I deployed the booru.

@GlassedSilver
Copy link
Contributor Author

GlassedSilver commented Jun 8, 2019

Nah, Im using Windows 10, remotely connected to my Ubuntu server VM where I deployed the booru.

Hang on here... Could it be I'm running the bundle install command on the wrong machine?

I am probably supposed to ssh into the machine and execute these commands on the actual server, remotely from my PC, right?

Because I thought the capistrano instance is suppose to be executed from my PC... Ooof... I can smell I've been the biggest potato ever the whole time.

Edit: well if I run bundle exec capistrano production deploy on my server itself (ssh'd into it) I get this error: Could not locate Gemfile or .bundle/ directory

What's my work directory supposed to be or what else could be off?

@GlassedSilver
Copy link
Contributor Author

@GlassedSilver
[...]
bundle exec cap production deploy

If during the bundle install you get a warning like "can't find gem bundler" it can be fixed by doing either:

a) gem install bundler -v 1.16.1
or
b) gem update --system and bundle install

After that you'll have to modify the script according to your setup and needs.
You can also use "bundle exec rails server" to run it without doing a deploy but I have never used it that way.

And regarding the warnings I don't know too much about that, hopefully someone else will answer it.

Okay so I tried your modified script and it definitely progressed pretty well for the most part.

I still got those weird warnings during the "yarn install" command, but since they were warnings and not errors I decided to try and go ahead anyways for now.

Now I'm having issues with "bundle exec cap production deploy".
I receive multiple errors like this one:

Traceback (most recent call last):
[SNIPPED] Exception while executing on host kagamihara: getaddrinfo: Temporary failure in name resolution (SSHKit::Runner::ExecuteError)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host kagamihara: getaddrinfo: Temporary failure in name resolution

@kdoshere
Copy link

kdoshere commented Jun 12, 2019

You're getting that error because you didn't customize your config/deploy/production.rb

As you can see at the end of the script you'll need to modify the mentioned files according to your needs and preferences.

the provided install script (your github repo url)
config/deploy.rb (your github repo url)
config/deploy/production.rb (your server's domain/ip and users, the default user created by the script is danbooru)
config/unicorn/production.rb (your users, the default user created by the script is danbooru)
config/application.rb (your time zone)

Create a fork of the danbooru repository, modify the files above with your domain/ip or whatever you'll be using and push the changes to your repository.

After that log in with the danbooru account, make sure to delete your old "/home/danbooru/danbooru" folder, do a git clone of your repository with "git clone git://your_repo_url.git ~danbooru/danbooru" and then finally, go to that folder and run the commands to do the deploy (yarn bundle install, etc).

@GlassedSilver
Copy link
Contributor Author

GlassedSilver commented Jun 12, 2019

You're getting that error because you didn't customize your config/deploy/production.rb

As you can see at the end of the script you'll need to modify the mentioned files according to your needs and preferences.

the provided install script (your github repo url)
config/deploy.rb (your github repo url)
config/deploy/production.rb (your server's domain/ip and users, the default user created by the script is danbooru)
config/unicorn/production.rb (your users, the default user created by the script is danbooru)
config/application.rb (your time zone)

Create a fork of the danbooru repository, modify the files above with your domain/ip or whatever you'll be using and push the changes to your repository.

After that log in with the danbooru account, make sure to delete your old "/home/danbooru/danbooru" folder, do a git clone of your repository with "git clone git://your_repo_url.git ~danbooru/danbooru" and then finally, go to that folder and run the commands to do the deploy (yarn bundle install, etc).

Woops, indeed, I did edit those files but I must have missed setting the IP since I used a new VM to start with a clean slate.

Now deploy errors out on pushing changes to my git repo??? Why the hell does it desire to write to my repo?

I've now git cloned https://github.com/..... instead of git:github.com/.... because it told me to use https instead of git. Still not sure why it insists on writing to my repo.

Edit: I see, it wants to create a marker. Fair enough, I guess but in my eyes more warning-worthy than worthy of failing a deploy? Nevermind.

Now it seems it did do all of its jobs, buuuut... when I point my browser to my server's URL all I get is the Welcome to nginx page. sigh

@kdoshere
Copy link

First you'll need to check if the deploy was successful, you should have seen a lot of information and by the end you should have gotten a "newrelic" error (just because some missing configuration) and then the unicorn and jobs were executed.

That means that if you're getting the nginx starter page you'll need to check your nginx configuration, so:

Go to "/etc/nginx/nginx.conf" and check if it has "include /etc/nginx/sites-enabled/*.conf;", add it if it doesn't and then reboot the services (nginx, danbooru, etc. or just reboot the VM).

You can do that using:
cd /var/www/danbooru/current
bundle exec cap production unicorn:start/stop
bundle exec cap production delayed_job:start/stop

Now you can try again and if it still doesn't work you can try the following:
a) The booruu is forcing the https connections, so you'll have to configure that according to your needs.
b) Disable the redirection: Add the following to the "/var/www/danbooru/shared/config/danbooru_local_config.rb" file, restart and check if it works.

def ssl_options
false
end

@GlassedSilver
Copy link
Contributor Author

by the end you should have gotten a "newrelic" error (just because some missing configuration)

Indeed, I did get that. (something about no license key being found)

Can't I configure it to not use New Relic? For what I'm going to use it for I have zero need for NR from what I understood about it and more importantly it's an external service for logging. No thanks. uwu

I did set the SSL mode to off, restarted the VM - still no good.

As for nginx.conf that file is looking good. It does have the line you mentioned.

Despite the issues right now I sense I'm THIIIS close to finally having a running deployment. That alone makes me super happy, that I received so much help from you guys so far, absolutely terrific and let it be known that I'm EXTREMELY grateful.

@kdoshere
Copy link

Well @GlassedSilver

edit :/etc/nginx/sites-enabled/danbooru.conf

and change: server 127.0.0.1:9000; for: server unix:/tmp/.unicorn.sock;

reload nginx/restart booru and check if it works.

@GlassedSilver
Copy link
Contributor Author

GlassedSilver commented Jun 14, 2019

Well @GlassedSilver

edit :/etc/nginx/sites-enabled/danbooru.conf

and change: server 127.0.0.1:9000; for: server unix:/tmp/.unicorn.sock;

reload nginx/restart booru and check if it works.

Okay, I'm slowly getting there... I think I can narrow it down.

I temporarily edited /etc/nginx/sites-enabled/danbooru.conf to use port 8080 instead of 80 and instead of getting no connection at all I am getting the "Faiilbooru" page when I browse to the server's IP:8080 which means I can already at least speak to the danbooru instance! Of course it expects to run on port 80 so that's why it errors, now all I need to do is make nginx not use the default page over danbooru for port 80.

Funny thing is... I removed default from sites-enabled and yes I rebooted... Still nothing.

This ought to be an nginx error. ponders Why is nginx is such a b....?

Edit: Alright. I changed the port back to 80 in the configuration file, issued "sudo nginx -s reload" and then browsed to my server's IP without port 8080, and it shows me the Failbooru page... I guess I'm happy enough I can target the instance on the proper port now... but why did danbooru itself error out? Investigating now. I'll keep you guys updated.

@GlassedSilver
Copy link
Contributor Author

Alright so in my endevor to troubleshoot the Failbooru page I tried to launch the rails console using "rails c" and alternatively "rails console" but apparently it's not installed? Does rails really not have a console ready to go by default or am I missing something here (yet again)?

I looked up a bunch of tutorials for rails console and apparently the whole world launches the console just fine using either of the commands I mentioned except my VM seems to know nothing about rails console.

(so far successfully tested the database using psql)

@evazion
Copy link
Member

evazion commented Aug 1, 2019

Closing this in favor of #4096.

@evazion evazion closed this as completed Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants