Our builds started to randomly fail on CircleCI when executing npm install:
12345678910111213141516171819202122
npm install
npm ERR! Could not get cache stat
npm ERR! Could not get cache stat
npm ERR! Could not get cache stat
npm ERR! Linux 3.14.28-031428-generic
npm ERR! argv "node" "/home/ubuntu/nvm/v0.10.32/bin/npm" "install"
npm ERR! node v0.10.32
npm ERR! npm v2.1.16
npm ERR! path /home/ubuntu/.npm/_git-remotes/git-github-com-SOMEPATH-ON-GITHUB-2799bac7/objects/pack/pack-ba6de98838bb215ca34b4ebaac78c6dbad04a80b.keep
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! enoent ENOENT, chown '/home/ubuntu/.npm/_git-remotes/git-github-com-SOMEPATH-ON-GITHUB-2799bac7/objects/pack/pack-ba6de98838bb215ca34b4ebaac78c6dbad04a80b.keep'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/PROJECT-NAME/npm-debug.log
npm install returned exit code 34
action npm install failed
Sometimes it would take re-running the build 3 or 4 times before going green.
Each failure was always due to installing via Git URL.
Adding ~/.npm/_git-remotes/ to the cache_directories of the circle configuration fixed the majority of these issues:
ember-cli uses broccoli for asset compilation and fingerprinting of asset file names.
When the environment is production, the addon will automatically fingerprint your js, css, png, jpg, and gif assets …
No fingerprinting occurs in the development environment. These are great defaults, but what if you have a staging environment and want to fingerprint those assets? You can override the fingerprint setting when the ember application is created.
12345
varapp=newEmberApp({fingerprint:{enabled:true}});
Now all environments will fingerprint assets, but we really don’t want that in development. Since the ember application has not booted up yet we do not have access to the configuration object directly – lucky for us it is available on the process object before the ember application is created.
This happened to me after re-installing my OS and using a fresh install of rbenv. I cloned my application repository and went to execute a bundle install and received the following error:
123456789101112
Fetching source index from http://rubygems.org/
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
What? rbenv should not be prompting me to use sudo, it was trying to install gems on the system version of ruby. Running rbenv local returned 2.1.4 as expected, what the heck was going on?
gem list | grep bundler returned nothing – doh! I didn’t have bundler installed via rbenv so it was falling back to the system ruby. I was not expecting it to use a different version of bundler.
1234
rbenv local
gem install bundler
rbenv rehash
bundle
Whenever I get new machine or re-install my OS I like to use pivotals sprout-wrap for the setup. I have been through the process many times and finally documented it back in October.
From the app store install XCode
open XCode and accept the terms, then close app
from the terminal run: xcode-select --install
copy ssh keys from old machine via airdrop
then install sprout-wrap dependencies using the built in version of Ruby that ships with Mac OS X:
1234567
sudo gem install soloist
sudo gem install bundler
mkdir installs
cd installs
git clone https://github.com/pivotal-sprout/sprout-wrap.git
cd sprout-wrap
sudo bundle
Modify the soloistrc file if desired; for me that means adding ‘sourcetree’, ‘hipchat’ and a few others to the casks section.
If you prefer SublimeText2 it is available as a cask and can be installed via soloist
then Encrypt your hard drive using FileVault2
Done! :)
NOTE: if you install sprout-wrap with defaults it will configure many os-x settings which you may or may not like; I personally do like them, especially the ‘Fast Key Repeat Rate’.
This post originally appeared on the private discussion board Ruby Rogues Parley.
So you need to display some datetimes in your new ember.js/angular/backbone UI and the times must be displayed for a timezone which is different from the logged on user.
Let us say we have an Event class in our rails application with the following attributes:
// where 'event' is the js representation of your rails modelmoment(event.startAt).tz(event.timeZoneMapping).format('dddd, MMMM Do YYYY h:mm a z');
You will want to ensure that all json is being rendered with UTC as the configured timezone in rails,
i.e. config.time_zone = 'UTC' in your application config and/or Time.zone = 'UTC' in your api controller.
Our CI server is setup to run rubocop (ruby linter) after every checkin.
On my local development machine I prefer to lint files that have recently changed and not the entire code base.
Add this code to a shell script and it will lint all files that have been staged.
Note it uses the autofix rubocop option, optionally you could run it on non-staged files without the autofix flag.