Puppet - Bundler does not install a gem from GitHub - github

I have a virtual machine where I want to run Rails application. I use Vagrant to run it and Puppet as the provision tool.
I want to run bundle install during the provision so the VM is ready. I use this:
exec { 'bundle install':
command => 'bundle install',
cwd => '/vagrant/',
logoutput => true,
}
All gems but one are installed. The problem is with ember-rails, which is the only one with a GitHub repo specified in Gemfile:
gem 'ember-rails', github: 'emberjs/ember-rails'
I think this must be a Puppet issue. When I ssh into the VM and run bundle install manually, the gem is downloaded and used. When running provision via Vagrant, Puppet logs this message, but the gem seems to be missing:
/Stage[main]/Bundler/Exec[bundle install]/returns: Using ember-rails (0.9.2) from git://github.com/emberjs/ember-rails.git (at master)
I have noticed one difference. When I run bundle install manually, Bundler logs this:
Fetching git://github.com/emberjs/ember-rails.git
However, there is no such message in the Puppet log. Any ideas what might be the problem?

Gems installed from git repos are only visible to Bundler and do not appear in gem list. This is normal and does not indicate a problem. Is there a problem actually running your app?

Related

Should a vscode dev container run npm install as part of its setup?

I've created a VS Code dev container for my project. To help new contributors get started, should the dev container Dockerfile run npm install?
No. Dev container define a development environment and should not perform actions that would be part of a normal development workflow (such as running npm install).
There are a couple of reasons why npm install in particular should be avoided:
If you run npm install in the dev container Dockerfile and it fails, the dev container will fail to launch. It's farbetter if the developer can open the dev container successfully, and then run npm install in an environment where they can investigate potential failures
npm install must be re-run when the project's dependencies change. Running npm install as part of dev container setup hides this from developers.
Dev container should only use npm install to install global scripts or tools that do not belong in the project's package.json.
It is actually good practice to call npm install as part of the dev container configuration. It eases and accelerate setup of the development environment, ensuring it's ready to use out of the box without extra steps possibly missed.
Note that the npm install must be in a postCreateCommand where sources and package.json are available (contrary to the Dockerfile).
Due to the nature of docker and devcontainer, there is very little reason for the npm install command to fail and need debugging. If it ever happen, VSCode logs will provide meaningful information, otherwise the postCreateCommand can be disabled quickly to investigate the issue.
There exists an official VSCode video, so we can assume calling npm install as part of the dev setup is a common practice: How to automatically run npm install in a dev container.

Does the self-contained version of fastlane support dev builds?

When using the version of fastlane installed from Homebrew, I don't know how to use a development build of a plugin. I see fastlane add_plugin still generates a Pluginfile. If I try adding gem "fastlane-plugin-xxx", git: "https://github.com/yyy/xxx" or something similar using a :path argument, it always tries to install the version from RubyGems.
I have two specific cases where this makes things inconvenient:
I'm building a new plugin for a client. I want mobile devs to review it internally before it is published.
A user reported an error from a published plugin. I want them to try a dev version from the master branch in order to get more information.
In both cases, I think it's necessary to use Ruby and the Bundler. Not everyone has lots of Ruby experience, so getting someone set up can be an obstacle.
Edited 2017-07-06:
Part of the answer is obvious. When you run fastlane add_plugin, it prompts you if it cannot find the gem:
[jdee#Jimmy-Dees-MacBookPro TestApp]$ fastlane add_plugin my_new_action
[10:46:28]: Seems like the plugin is not available on RubyGems, what do you want to do?
1. Git URL
2. Local Path
3. RubyGems.org ('fastlane-plugin-my_new_action' seems to not be available there)
?
This works well with the fastlane gem, e.g. with RVM:
gem install fastlane
fastlane add_plugin my_new_action
The self-contained binary from Homebrew also prompts you for a Git URL or a local path, but I consistently get build failures from native extensions in the json gem on OS X Sierra. This may be due to plugin dependencies, but I'm not sure. This can still be a little awkward for the use cases above, and I'm surprised that this fails with the self-contained version, which I'd expect to be more robust than using Ruby. At least this removes the need for bundle install and bundle exec.
The answer here is basically that the self-contained version of Fastlane does not really work with plugins. In particular, when fastlane add_plugin or fastlane install_plugins runs bundle install, it tries to install the json gem, a dependency of the fastlane gem, which has native dependencies, and it cannot find <stdio.h>, presumably because /usr/include is screened out in the self-contained bundle in order to insulate it from the system Ruby. After this, you can run bundle install and bundle exec yourself, but in general a Gemfile is required to work with Fastlane plugins. The CLI will even tell you to run bundle exec once you have a Gemfile.
When using the fastlane gem, fastlane add_plugin will usually work, but again you will have a Gemfile and want to run bundle exec fastlane afterward.
You can just modify your Pluginfile to use a path or a git repo and rerun bundle install. There's not a much easier way to do this at the moment.

How to require local vagrant plugin (vagrant 1.5.0.dev)

How can I require plugin that im currently developing without publishing it to the rubygems? Before I could require with Vagrant.require_plugin, but now Its printing me out that its deprecated.
here's my gemfile
source 'https://rubygems.org'
gem 'bundler'
gem "vagrant", github: "mitchellh/vagrant"
group :plugin do
gem 'vagrant-sheogorath', :path => '/Users/sandric/vagrant-sheogorath/'
end
here's my Vagrantfile:
require "vagrant-sheogorath"
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
when I'm running bundle exec vagrant plugin list here's the output:
sandric#sandric-mac ~/v/provision> bundle exec vagrant plugin list
Vagrant appears to be running in a Bundler environment. Your
existing Gemfile will be used. Vagrant will not auto-load any plugins.
You must load any plugins you want manually in a Vagrantfile. You can
force Vagrant to take over with VAGRANT_FORCE_BUNDLER.
You appear to be running Vagrant outside of the official installers.
Note that the installers are what ensure that Vagrant has all required
dependencies, and Vagrant assumes that these dependencies exist. By
running outside of the installer environment, Vagrant may not function
properly. To remove this warning, install Vagrant using one of the
official packages from vagrantup.com.
No plugins installed.
and when I try to install it:
sandric#sandric-mac ~/v/provision> bundle exec vagrant plugin install vagrant-sheogorath
Vagrant appears to be running in a Bundler environment. Your
existing Gemfile will be used. Vagrant will not auto-load any plugins.
You must load any plugins you want manually in a Vagrantfile. You can
force Vagrant to take over with VAGRANT_FORCE_BUNDLER.
You appear to be running Vagrant outside of the official installers.
Note that the installers are what ensure that Vagrant has all required
dependencies, and Vagrant assumes that these dependencies exist. By
running outside of the installer environment, Vagrant may not function
properly. To remove this warning, install Vagrant using one of the
official packages from vagrantup.com.
Installing the 'vagrant-sheogorath' plugin. This can take a few minutes...
ERROR warden: Error occurred: Vagrant's built-in bundler management mechanism is disabled because
Vagrant is running in an external bundler environment. In these
cases, plugin management does not work with Vagrant. To install
plugins, use your own Gemfile. To load plugins, either put the
plugins in the `plugins` group in your Gemfile or manually require
them in a Vagrantfile.
It seems that you don't need to install plugins while developing. You just need to include it in the :plugin group of your Gemfile, and Vagrant should load it for you at runtime.
By the way, on the repository master branch an updated version of the plugin development doc page already exists.

Can't run cloned repository

How do I download my old code from github? I made a mistake on my app, and when I try to download the old zip file from github and run it I get an error.
I think I'm doing it right, don't I just need to clone the repository? When I do, i get this error when I try to run the server:
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
and when I run bundel install I still get the error.
I also get this error:
bundle install doesn't work and I still get the error along with this one:Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
It ssems to me that you do not have install Postgres. Install it and try bundle install again.
How install Postgres on Ubuntu (of course you can have another system :) ) - https://help.ubuntu.com/community/PostgreSQL
If you have installed Mavericks, that is the source of your problem. I had to install another gem with native dependencies that needed to be compiled after I installed Mavericks, and some changes as to which compiler Mavericks uses to compile gem dependencies creates problems. In your case, I would suggest you pick one of the solutions in this answer to resolve your PG installation problems.

Error when pushing data to Heroku: time zone displacement out of range

I run the following command to push the contents of my local database to Heroku:
heroku db:push --app my-app
From my home computer this works flawlessly but from my work computer I get this error:
Taps Server Error: PGError: ERROR: time zone displacement out of range: "2011-11-15 12:00:00.000000+5894114400"
I'm not sure where that date is coming from, I can't find it in the data anywhere. Any ideas what's going on and/or how to fix it?
Using Ruby 1.9.2-p290 instead of 1.9.3-p0 fixed it for me. According to Roger Braun, this is the reason:
The problem is (I think), that marshalling changed between Ruby 1.9.2
and 1.9.3, so this is not really a taps error. Just use whatever
version heroku runs to push and pull databases (Probably 1.9.2).
Downgrading to Ruby 1.9.2 from Ruby 1.9.3 does not sound like an appealing option to me.
Heroku's devcentre page actually suggests using pgbackups addon to managing databases ( https://devcenter.heroku.com/articles/pgbackups) . It may sound like it's only for taking backups of production databases down to your local machine but if you read it carefully, they have a large section which deals with "importing a database". What they suggest is that you upload your database to a publically accessible location and run the suggested command
heroku pgbackups:restore DATABASE 'http://s3.amazonaws.com/.....mydb.dump?authparameters'
So, in effect they provide commands to dump your local database, suggest ways to upload it to a location that heroku's servers can fetch your database dump from (assuming your local development machine is not publically accessible from the internet) and then the above command for it to be uploaded into production environment on heroku.
Just putting this up here, since i think problem has been persisting for a very long time without adequate resolution on the real problem.
I run 1.9.3p125 on Heroku and 1.9.3p125 on my local machine. If I want to db:push I just switch to 1.9.2 while uploading:
rvm use ruby-1.9.2-p290
heroku db:push --app my-app
rvm use ruby-1.9.3-p125
Then once the push is complete, I switch back to 1.9.3.
It didn't work for me either using 1.9.3 or 1.9.2.
As Pablo pointed out the problem has to do with the marshalling of the dates (the marshalling converts the date to 12:00:00+XXXX" despite my date type was 'timestamp without timezone').
Anyway, I worked it around by setting the dates to null, so I could successfully push to Heroku. Very poor solution, though. I hope the bug will get fixed soon.
On my platform of choice (gentoo linux) Ruby 1.9.2 is not available anymore. Anyway a version of ruby 1.8.x can be installed at the same time.
Here is how I worked around the issue:
$ eselect ruby list
Available Ruby profiles:
[1] ruby18 (with Rubygems)
[2] ruby19 (with Rubygems) *
$ sudo eselect ruby set 1
Password:
Successfully switched to profile:
ruby18
Now I had to temporally comment from my project Gemfile all the gems that don't work with ruby 1.8 (for example paperclip)
$ bundle install
& bundle exec heroku db:push
Uncomment from Gemfile what was commented before
$ sudo eselect ruby set 2
Password:
Successfully switched to profile:
ruby19
Not a clean solution but at least works fine.
Just changing the ruby version has not worked for me. Instead I've narrowed down the issue to the new Heroku Toolbelt.
When using the older heroku gem I'm able to db:push just fine. Until heroku fixes it i've created a new gemset and installed the heroku gem. I just switch to this gemset whenever I need to do a db:push.
Which Heroku stack are you on? If you are on bamboo-ree-1.8.7 the right version to use is 1.8.7. This is a marshalling problem and can be solved by using the same Ruby version on both the server and the client.
Try to use native taps without heroku db:push.
taps server POSTGRES_DATABASE_REMOTE_URL login pass
taps push sqlite://db/development.sqlite3 login:pass#localhost:5000
solved the problem for me
It helped me to solve my problem, very practical https://github.com/ricardochimal/taps/issues/92#issuecomment-11996909
On win7-x64, creating app in heroku's cedar and setting pik (rvm-alternative) to use ruby 1.9.2 worked. In a nutshell, what I did:
created a new heroku app in cedar stack (running ruby-1.9.2)
heroku create -s cedar
installed pik (rvm-alternative), then followed the post-install instructions
gem install pik
installed ruby-1.9.2p290, added <RUBY192_INSTALL_DIR>/bin to $env:PATH
installed DevKit to ruby-1.9.2
ensured all necessary gems are installed in both ruby versions, 1.9.3 and 1.9.2
pik gem install <gem-1> <gem-2> ... <gem-n>
specified db gems for production, development, and test environments in Gemfile
# Development + Test:
group :development, :test do
gem 'pg', :platforms => :mingw
end
# Heroku:
group :production do
gem 'thin'
gem 'pg'
end
removed platform refs to mingw32 in Gemfile.lock after
bundle install
added new edits in Gemfile and Gemfile.lock (generated) to repo
git add .
git commit -am "rebuilt Gemfile for Heroku"
git push heroku master
raked up data models, pushed local data up
heroku run rake db:migrate
heroku db:push
heroku open
then switched back to ruby-1.9.3
pik use 193
Finally got this to work with help from Dosha's answer here. (And thank you to hernanvicente above for the tip.)
Make sure your version of ruby matches the version running on Heroku. It seems like 1.9.2 is the stablest version for these migrations.
Change your gemfile to have the following (assuming you're using SQLite):
group :development do
gem 'taps', :require => false
gem 'sqlite3'
end
This likely still does not resolve your problem because your heroku db:push command is using the Heroku toolbar instead of the older, now-deprecated heroku gem. Unfortunately, we actually want the older gem, but the Heroku Toolbar is being called by heroku. To get around this, you will need to install the heroku gem on your version of ruby 1.9.2 and then access it by its specific filepath.
So, the next steps show how you can get this to work:
Run the following commands into your console:
rvm install ruby-1.9.2-p320
rvm use ruby-1.9.2-p320
bundle install`
sudo gem install heroku --no-ri --no-rdoc
Then run:
rake assets:clean
bundle exec rake assets:precompile
Commit your changes to Github.
Then enter the following into your console:
~/.rvm/gems/ruby-1.9.2-p320/gems/heroku-2.40.0/bin/heroku db:push
(Use your own filepath, if it's different from this.)