Gemfile git branch for Beanstalk unable to bundle install - ruby

In my Gemfile I have
gem 'slim', :git => 'git://github.com/brennancheung/slim.git', :branch => 'angularjs_support'
which is a branch of the slim gem required for me to run AngularJS correctly with my views. I've pushed my code to my beanstalk application but am unable to bundle install according to the logs shown below...
sh: git: command not found
Git error: command `git clone 'git://github.com/brennancheung/slim.git'
"/usr/share/ruby/1.9/gems/1.9.1/cache/bundler/git/slim-700ed452e752ccb6baf9de9d0a46fbded8bb2da5"
--bare --no-hardlinks` in directory /var/app/ondeck has failed.
I'm new to Beanstalk and have no idea how to fix this. Any help on how to get bundle to install successfully would be greatly appreciated. Thanks.

Since git is not installed on by default on EC2 instance, you would have to find a workaround solution:
a. Install git on instance with configuration file and command.
It is the most obvious way to solve the problem, although not be the most efficient.
b. Clone slim repository into your project, so it will be deployed together.
Seems that slim is not being actively developed lately, so having the copy in your project might not be a bad idea. It protects you from github.com being down, yet you will have extra files to carry around.
c. Use configuration file and commands to pull the data from github.com directly with http.
Too many files to work with, and also dependency on third party service.
d. Use a combination of above. Clone slim repository and copy files to S3. Use configuration and commands to copy files from S3 to your instance.
It seems like the most elegant and efficient way to solve the problem.
It might look something like:
$ cat .ebextensions/myapp.config
commands:
10-copy-slim-from-s3
command: "aws s3 cp s3://mybucket/slim slim --recursive"

Related

CircleCI and AWS CodeDeploy: No such file or directory

I've got a Ruby application that has been deployed to an AWS instance using CodeDeploy via CircleCI. I added a gem to the application. All tests are passing both locally and in CircleCI, but the deployment stage fails with this error:
$ create_application_revision /tmp/codedeploy_applications.json /tmp/codedeploy_revisions.json
create_application_revision loaded: {"applications":[{"application_root":"/","region":"us-west-2","revision_location":{"revisionType":"S3","s3Location":{"bucket":"something","key":"etl-scripts-testdeploy-3a050b1"}},"deployment_group":"EtlScriptsFleet","application_name":"EtlScripts"}]}
Bundling EtlScripts from /home/ubuntu/etl-scripts
Unhandled exception
[Errno 2] No such file or directory: '/home/ubuntu/etl-scripts/vendor/bundle/ruby/2.2.0/gems/regexp-examples-1.1.4/db/unicode_ranges_2.1.pstore'
It's true that file doesn't exist. It doesn't exist locally either, but all tests pass. I just can't figure out why the deployment process thinks it needs this file?
I noticed that in the source code for this gem (https://github.com/tom-lord/regexp-examples/tree/master/db) is a symbolic link and that's probably why it's not being created. But I'm still confused about how the deployment bundle process would know about a non-existant symbolic link.
Any help greatly appreciated!
It seems the deployment stage is being handled by the deploy push command from aws CLI, and it cannot handle broken symlinks.
I could reproduce the problem by trying to deploy an app containing a broken symlink using the push command:
(Command - aws deploy push --application-name --s3-location s3:///.zip --source ./)
(Output - [Errno 2] No such file or directory: '/path/to/source/')
I guess you will need to manually remove all broken symlinks for the deployment to succeed.
For what it's worth, this gem was later refactored to not use symbolic links; as of v1.3.0.
Upgrading from your current version (1.1.4) should almost certainly require no code change.

Install wkhtmltopdf on heroku using a java application

I manged to get my spring boot website online on Heroku. But I also use wkhtmltopdf to create a pdf. This works locally but now I have some problems.
Offline it works as follow :
ProcessBuilder pb = new ProcessBuilder
("cmd.exe",
"/c",
" cd C:\\Program Files\\wkhtmltopdf\\bin && wkhtmltopdf.exe "
+ "http://google.com C:\\MainWebApps\\TestApp\\src\\main\\resources\\userstorage\\Google2.pdf");
But how do I install this on Heroku?
Where do I store the temporarily html page so I can create a pdf from it ?
And where is wkhtmltopdf installed on Heroku ?
Can I call the wkhtmltopdf with a processbuilder on heroku?
EDIT
So after the comment of ceejayoz I googled a bit more and did find some interesting stuff.
So for Compile the binaries on Heroku I used this:
heroku run /bin/bash
Then I did a curl of wkhtmltopdf like this:
curl -O http://download.gna.org/wkhtmltopdf/0.12/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
Then I tried to extract it on the server but without success:
$ tar -xjvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
tar (child): wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
EDIT2
I also found this https://github.com/dscout/wkhtmltopdf-buildpack on github.
So I did following :
heroku buildpacks:set 'https://github.com/heroku/heroku-buildpack-multi.git'
echo 'https://github.com/dscout/wkhtmltopdf-buildpack.git' >> .buildpacks
This created a file named .buildpacks but how do I proceed from there on ?
I also found this post but vulcan is deprecated and uses ruby
Using Wkhtmltopdf with Nodejs on Heroku
Can somebody provide me with good information because I am completely stuck with this?
You actually have two problems that you need to solve -
How to install/invoke the executable
How to handle the generated .pdf
Assuming you have the basics of Heroku deployment (push to the Heroku git remote), for #1, #ceejayoz is right - check the binary into your git repository. For example, under a ./bin directory. The root of your project (where the Procfile is) will be your working directory, and you should be able to invoke the program with ProcessBuilder using relative paths.
Caveat - since it looks like you are developing on Windows, you will need to pay attention to ensuring both platform-specific binaries are available, and add some logic to know which one to invoke (for example, by setting/checking a specific environment variable).
I recommend against trying to build with a custom build pack - you will spend a lot of energy for little to no benefit. Aside from the platform issue, you don't need to rebuild a third party tool when your code changes...
The second problem is that you can't leave the generated PDF in place. It will go away when the dyno is restarted (see https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Thus, the first thing you should do when the process completes is move the generated file to an external storage service (Amazon S3 is a good starting point).
Hope this helps.
You might want to use wkhtmltopdf-binary. With that solution, you do not need to put wkhtmltopdf executable into your VCS. You can use it for example with Maven or Gradle.

Git bundled into Cocoa app cannot find helpers in bundle

Context:
I have a Mac app. I want to include Git in this app because some functions of my app use Git and I don't want the user to have to install it on his machine.
I have downloaded Git from source. I edited the Makefile to declare these two lines:
NO_GETTEXT="yesPlease"
CURLDIR=/usr/local
The first line tells the build process to skip localizing and just use English.
The second line declares the path to where libcurl is installed. I downloaded libcurl_devel and built it from source. This is required to enable Git to pull/push from http and https repos.
Git builds successfully. I then copy all of the resulting files into my app's bundle. I'm using NSTask to run Git and attempt to pull an https://-based repo.
The Problem:
The error I get is:
fatal: Unable to find remote helper for 'https'
I googled this, and everyone said that as long as I had libcurl installed when I built Git, Git would work with HTTP and HTTPS addresses. And, in fact, if I run the installed Git from the command line, it does!
What I Need:
So, I must be missing a path setting or an environment variable or SOMETHING that tells Git where to find those remote helpers. They ARE in my app bundle; the screenshot below shows them:
So: what the hell do I need to set in order to resolve this problem when I run Git from within my application bundle?
Unbelievable. I've been trying to fix this for 8+ hours and five minutes after I finally break down and post this question, I figure it out:
Git has an option called --exec-path. I had been passing this argument to the NSTask like this (Where APP BUNDLE is replaced by the path to the application bundle on the user's machine):
--exec-path=[APP BUNDLE]/git/bin
Since bin was the folder where the Git binary was located, I figured that was the appropriate path. However, if I do this:
--exec-path=[APP BUNDLE]/git/libexec/git-core
It works.

Update gem on staging server only

I want to update one of my gems on staging server ONLY. So, I'm running
bundle update gemname
or
bundle install
but then I got error:
You have modified your Gemfile in development but did not check the resulting snapshot (Gemfile.lock) into version control
The problem is that I can't do it locally and I can't push it into git repository. Any ideas how to solve it?
OK, my problem was specific and quite rare, because I could't deploy app with new features due to situation with my client. Maybe it sounds awful, but at first I got to locally update my Gemfile, run bundle install, manually copy Gemfile.lock to my server and after all I could update gems as I want to. It works at now and when I will be allowed to deploy whole app code with capistrano, everything will be fine.
You can create groups in your Gemfile like this in your case:
group :staging do
gem 'gem_name', 'gem_version'
end
Only put the gems that you want to use in that specific environment.
Hope this helps :)

Cloning repository from ruby

I'm creating a Sinatra app that will pull in data from a remote git repository.
I've taken a look at the ruby-git gem, but I get cannot load such file -- git on the line of require 'git'. The gem is installed and in my Gemfile.
I'm not sure if this is the correct way about going about this, but essentially I want the app to checkout a git repository for pulling in data.
Ended up using the system command:
system("git clone #{$config['repository']} content")

Resources