Capistrano RBENV path production error: failed: "env PATH=/home/user_with_rbenv/.rben - capistrano

I have 2 SSH users. 1 which have rbenv installed.
I have watched the railscast about deploying to a VPS and some users have solved the problem with added the rbenv path.
set :default_environment, {
'PATH' => "/home/user_with_rbenv/.rbenv/shims:/home/user_with_rbenv/.rbenv/bin:$PATH"
}
I am deploying from the user that does not have .rbenv included in its /home/user folder.
I get the following error:
←[2;37mcommand finished in 117ms←[0m
failed: "env PATH=/home/user_with_rbenv/.rbenv/shims:/home/user_with_rbenv/.rbenv/bin:$PATH sh -
c 'cd -- /var/www/user_with_rbenv/releases/20130215102746 && bundle exec rake RAILS_ENV=
production RAILS_GROUPS=assets assets:precompile && cp -- /var/www/app/share
d/assets/manifest.yml /var/www/app/releases/20130215102746/assets_manifest.y
/home/user_with_rbenv/.rbenv is the absolute path to the rbenv
And path is:
$ $PATH
-sh: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: not found

Related

Elastic Beanstalk failed to unzip source file with UTF-8 file name

I was trying to deploy a NextJS application to Elastic Beanstalk via eb deploy. But the source bundle failed to unzip during deployment as the source bundle contained some pre-built .next page which the file name is in UTF-8 encoding. The error is stated as below.
2022/xx/xx xx:xx:xx.xxxxxx [INFO] Executing instruction: StageApplication
2022/xx/xx xx:xx:xx.xxxxxx [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2022/01/31 04:56:44.300483 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2022/01/31 04:56:45.932820 [ERROR] An error occurred during execution of command [app-deploy] - [StageApplication]. Stop running the command. Error: Command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/ failed with error exit status 50. Stderr:error: cannot create /var/app/staging/.next/server/pages/\u6e2c\u8a66/\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66.html
File name too long
error: cannot create /var/app/staging/.next/server/pages/\u6e2c\u8a66/\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66\u6e2c\u8a66.json
File name too long
I was able to unzip the file with option -O UTF-8, is there any way I could add this flag to the eb deploy unzip process?
edit 1. I am working with the Platform 64bit Amazon Linux 2/5.4.9
Not sure if it is good practice, but I eventually added an ebextensions to overcome the original unzipping flow.
commands:
command backup original zip:
command: |
logger "backup zip" && cp /opt/elasticbeanstalk/deployment/app_source_bundle /tmp/app_source_bundle_bak &&
logger "rm existing zip .next folder" && zip -Ad /opt/elasticbeanstalk/deployment/app_source_bundle ".next/*"
cwd: /home/ec2-user
ignoreErrors: false
container_commands:
replace the original zip to staging:
command: |
logger "custom unzip" &&
unzip -O UTF-8 -q -o /tmp/app_source_bundle_bak -d /var/app/staging/
cwd: /home/ec2-user
ignoreErrors: false

Getting error "Not Found" when the script is trying to find .sh in Dockerfile

DockerFile - Path is rootDirectory/odm-ondocker/decisionserver/decisionserverconsole.
ARG FROMLIBERTY
FROM maven:3.5.2-jdk-8-alpine AS builder
ARG ODMDOCKERDIR
ENV ODMDOCKERDIR $ODMDOCKERDIR
ENV SCRIPT /script
ENV APPS /config/apps
COPY $ODMDOCKERDIR/welcomepage /welcomepage
COPY $ODMDOCKERDIR/common/script $SCRIPT
COPY $ODMDOCKERDIR/common/drivers /config/resources
COPY $ODMDOCKERDIR/common/features $SCRIPT
COPY $ODMDOCKERDIR/decisionserver/decisionserverconsole/script $SCRIPT
COPY $ODMDOCKERDIR/decisionserver/decisionserverruntime/script $SCRIPT
# Use production liberty if needed
RUN echo $SCRIPT
COPY $ODMDOCKERDIR/resources/* /wlp-embeddable/
RUN chmod a+x $SCRIPT/fixWLPForProduction.sh && sync && $SCRIPT/fixWLPForProduction.sh
# Install missing require package in the alpine builder image
RUN apk add --no-cache bash perl ca-certificates wget
# Build Welcome page
RUN cd /welcomepage; mvn -B clean install | grep -v 'Download.*' && mkdir -p $APPS
I am getting error on line RUN chmod a+x $SCRIPT/fixWLPForProduction.sh && sync && $SCRIPT/fixWLPForProduction.sh as below:-
/bin/sh: /script/fixWLPForProduction.sh: not found
ERROR: Service 'odm-decisionserverconsole' failed to build: The command '/bin/sh -c chmod a+x $SCRIPT/fixWLPForProduction.sh && sync && $SCRIPT/fixWLPForProduction.sh' returned a non-zero code: 127
I am new to docker so not able to figure out why it's coming although the file is present inside root directory/common/scripts folder. I figured out, it's trying to find script folder which is under /odm-ondocker/common/script. I tried giving value of SCRIPT variable as /common/script but still it's giving as Not Found.
RUN chmod a+x $SCRIPT/fixWLPForProduction.sh && sync && $SCRIPT/fixWLPForProduction.sh
is looking for the script /script/fixWLPForProduction.sh as defined by your ENV SCRIPT command. But you said in your comment the script is /common/script/fixWLPForProduction.sh Trying using this instead
ENV SCRIPT /common/script Or use the absolute path for the script. From there, you can know how to properly set your ENV variable

rpm build fails to make build root dir

I am working on making an rpm for a small program used within our enterprise. The %build section of the rpm process works. I'm having trouble with the install section. I've referenced this article response and I believe I am properly referring to the target location with respect to %{_buildroot}.
The program I'm making is to be installed as a system service. So, after the rpm actually is generated for this step, I've got to add the next step in my installation process which is to include the script that is installed to the init.d location and run that install. One step at a time though.
The build errors are as follows (omitting everything but %install):
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.eUDaCK
+ umask 022
+ cd /home/packager/rpmbuild/BUILD
+ '[' /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 '!=' / ']'
+ rm -rf /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
++ dirname /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ mkdir -p /home/packager/rpmbuild/BUILDROOT
+ mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ cd o2arbitord-1.0
+ LANG=C
+ export LANG
+ unset DISPLAY
+ install -m 555 /home/packager/rpmbuild/BUILD/o2arbitord-1.0/o2arbitord /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin
install: cannot create regular file `/home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.eUDaCK (%install)
Now, my rpmbuild directory does not have the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin. While I know that's part of the problem, the rpmbuild process isn't making the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 either. What I don't understand about that one is: why? Looking at the script output above you can clearly see the line: mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64. So, why isn't the directory made?
How does the line BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) from whatever the definition of %{_buildroot} is? I thought that was the definition, but it appears to be something different.
For reference, my spec file
Name: o2arbitord
Version: 1.0
Release: 1%{?dist}
Summary: a daemon
Group: Applications/System
License: GPL
URL: http://My.site
Source0: %{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: x86_64
BuildRequires: libusb1-devel
#Requires:
%description
%prep
%setup -q
%build
make -f o2arbitord.mk
%install
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/sbin/o2arbitord
%changelog
You are attempting to install a file into a directory that doesn't exist (yet).
RPM only creates the %{buildroot} for you automatically. Anything under that you need to create yourself.
So when you run
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
where %{buildroot}%{_sbindir} expands to /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin RPM has only created /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 for you already.
You need to create the /usr/sbin part of that path and then copy the file into it.
You can do that with either
%{__mkdir_p} '%{buildroot}%{_sbindir}'
or
%{__install} -d '%{buildroot}%{_sbindir}'
Where
$ rpm -E '__mkdir_p = %{__mkdir_p}'
__mkdir_p = /bin/mkdir -p
$ rpm -E '__install = %{__install}'
__install = /usr/bin/install

rails 4 + mina deployment failure

i am deploying a rails 4 application using mina deployment. my deployment script is as
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm' # for rvm support. (http://rvm.io)
set :domain, 'someplace.com'
set :deploy_to, '/home/deploy/projects/website'
set :repository, 'git#github.com:someone/repo.git'
set :branch, 'master'
set :identity_file, "#{ENV['HOME']}/.ssh/id_rsa"
set :user, 'deploy' # Username in the server to SSH to.
set :shared_paths, ['config/database.yml', 'config/credentials.yml', 'log', 'tmp']
task :environment do
invoke :'rvm:use[ruby-2.1.0#default]'
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/shared/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
queue! %[mkdir -p "#{deploy_to}/shared/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
queue! %[touch "#{deploy_to}/shared/config/credentials.yml"]
queue %[echo "-----> Be sure to edit 'shared/config/credentials.yml'."]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:assets_precompile'
to :launch do
queue "touch #{deploy_to}/tmp/restart.txt"
end
end
end
when i deploy as 'mina deploy', i get error as
...
Symlinking shared paths
$ mkdir -p "./config"
$ mkdir -p "."
$ rm -rf "./config/database.yml"
$ ln -s "/home/deploy/projects/website/shared/config/database.yml" "./config/database.yml"
$ rm -rf "./config/credentials.yml"
$ ln -s "/home/deploy/projects/website/shared/config/credentials.yml" "./config/credentials.yml"
$ rm -rf "./log"
$ ln -s "/home/deploy/projects/website/shared/log" "./log"
$ rm -rf "./tmp"
$ ln -s "/home/deploy/projects/website/shared/tmp" "./tmp"
-----> Installing gem dependencies using Bundler
$ mkdir -p "/home/deploy/projects/website/shared/bundle"
$ mkdir -p "./vendor"
$ ln -s "/home/deploy/projects/website/shared/bundle" "./vendor/bundle"
$ bundle install --without development:test --path "./vendor/bundle" --binstubs bin/ --deployment
...
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
-----> Precompiling asset files
$ RAILS_ENV="production" bundle exec rake assets:precompile RAILS_GROUPS=assets
rake aborted!
File exists # dir_s_mkdir - /home/deploy/projects/website/tmp/build-138935597031149/tmp
/home/deploy/projects/website/tmp/build-138935597031149/vendor/bundle/ruby/2.1.0/gems/sprockets-2.10.1/lib/sprockets/cache/file_store.rb:25:in `[]='
/home/deploy/projects/website/tmp/build-138935597031149/vendor/bundle/ruby/2.1.0/gems/sprockets-2.10.1/lib/sprockets/caching.rb:34:in `cache_set'
Make sure that shared/tmp directory is created if not ssh into the server and
$ mkdir /home/deploy/projects/website/shared/tmp
make sure you have the right permissions too.
drwxr-xr-x
If you are symlinking your tmp directory ensure that it exists. If it doesn't the broken symlink will cause the same issue.

Capistrano Rails Asset Precompile Error

I have a Capistrano script which is deploying my app to an Amazon EC2 machine. It is failing when compiling assets:
* executing "cd -- /home/ec2-user/uc_social_server/releases/20130731161645 && RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile"
servers: ["ec2-23-22-188-11.compute-1.amazonaws.com"]
[ec2-23-22-188-11.compute-1.amazonaws.com] executing command
** [out :: ec2-23-22-188-11.compute-1.amazonaws.com] Could not find thread_safe-0.1.0 in any of the sources
** [out :: ec2-23-22-188-11.compute-1.amazonaws.com]
** [out :: ec2-23-22-188-11.compute-1.amazonaws.com] Run `bundle install` to install missing gems.
** [out :: ec2-23-22-188-11.compute-1.amazonaws.com]
command finished in 591ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/ec2-user/uc_social_server/releases/20130731161645; true"
servers: ["ec2-23-22-188-11.compute-1.amazonaws.com"]
[ec2-23-22-188-11.compute-1.amazonaws.com] executing command
command finished in 201ms
failed: "sh -c 'cd -- /home/ec2-user/uc_social_server/releases/20130731161645 && RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile'" on ec2-23-22-188-11.compute-1.amazonaws.com
Adding following to deploy.rb
require "bundler/capistrano"
require "rvm/capistrano"
before "deploy:assets:precompile", "bundle:install"
and following to Capfile
load 'deploy/assets'
and following to Gemfile
gem 'rvm-capistrano'
resolved the issue for me. If you are not using rvm, maybe you will not need to require rvm/capistrano or the rvm-capistrano gem.
Add this line to your Capfile
require 'capistrano/bundler'