zsh: Heroku toolbelt not found anymore - ruby

I recently switched to zsh, pretty happy about that. Except that the heroku toolbelt doesn't work anymore ...
Here is what I have when I type heroku -v :
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find heroku (>= 0) amongst [actionmailer-3.2.13, actionpack-3.2.13, activemodel-3.2.13, activerecord-3.2.13, activeresource-3.2.13, activesupport-3.2.13, arel-3.0.2, bcrypt-ruby-3.0.1, bootstrap-sass-2.3.1.0, builder-3.0.4, bundler-1.3.5, climate_control-0.0.3, cocaine-0.5.1, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.6.2, daemons-1.1.9, devise-2.2.3, erubis-2.7.0, eventmachine-1.0.3, execjs-1.4.0, faraday-0.8.7, haml-3.1.4, hashie-1.2.0, hike-1.2.2, httpauth-0.2.0, i18n-0.6.1, journey-1.0.4, jquery-rails-2.2.1, json-1.7.7, jwt-0.1.8, mail-2.5.3, mime-types-1.23, mime-types-1.22, multi_json-1.7.3, multi_json-1.7.2, multipart-post-1.2.0, oauth2-0.8.1, omniauth-1.1.3, omniauth-facebook-1.4.1, omniauth-oauth2-1.1.1, orm_adapter-0.4.0, paperclip-3.4.1, pg-0.15.1, polyglot-0.3.3, rack-1.4.5, rack-cache-1.2, rack-ssl-1.3.3, rack-test-0.6.2, rails-3.2.13, railties-3.2.13, rake-10.0.4, rdoc-3.12.2, rubygems-bundler-1.1.1, rvm-1.11.3.7, sass-3.2.9, sass-rails-3.2.6, sprockets-2.2.2, thin-1.5.1, thor-0.18.1, tilt-1.4.1, tilt-1.3.7, treetop-1.4.12, tzinfo-0.3.37, uglifier-2.1.0, warden-1.2.1] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/heroku:22:in `<main>'
I tried to reinstall the toolbelt since I read about it, but same result happen.
I compared bash and zsh $PATHs but they seem to contain the same pointers to heroku folders :
Bash:
/usr/local/heroku/bin:/home/augustin/.rvm/gems/ruby-1.9.3-p392/bin:/home/augustin/.rvm/gems/ruby-1.9.3-p392#global/bin:/home/augustin/.rvm/rubies/ruby-1.9.3-p392/bin:/home/augustin/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/google/google_appengine:/usr/local/heroku/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/google/google_appengine:/home/augustin/.rvm/bin:/home/augustin/.rvm/bin
Zsh:
/home/augustin/.rvm/gems/ruby-1.9.3-p392/bin:/home/augustin/.rvm/gems/ruby-1.9.3-p392#global/bin:/home/augustin/.rvm/rubies/ruby-1.9.3-p392/bin:/home/augustin/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/google/google_appengine:/usr/local/heroku/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/google/google_appengine:/home/augustin/.rvm/bin
I have read about installing heroku gem since I have ruby errors, but I also read it's depreciated since the toolbelt exists: https://github.com/robbyrussell/oh-my-zsh/issues/1401
So where is the problem?
I'm pretty new to Ruby, I still don't understand everything about rvms and I have the feeling my error is linked to it.
Finally, here is my .zshrc file, which I think could help too.
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
#ZSH_THEME="muse"
ZSH_THEME="ys"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment to change how often before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want to disable command autocorrection
# DISABLE_CORRECTION="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails rails3 git textmate ruby lighthouse)
source $HOME/.aliases
plugins=(git ruby rails rails3 rvm heroku)
source $ZSH/oh-my-zsh.sh
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && . “$HOME/.rvm/scripts/rvm”
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi
# Customize to your needs...
export PATH=$PATH:/usr/local/heroku/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/google/google_appengine:/home/augustin/.rvm/bin
Great thanks in advance.

edit the last line of ~/.zshrc and change it to:
export PATH=/usr/local/heroku/bin:$PATH:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/games:/usr/local/games:/opt/google/google_appengine

just put in you terminal :
sudo snap install --classic heroku

Related

zsh is not changing theme

Im trying to change the theme of zsh but I can't figure out what the problem is. This item didn't help me, because as you can see in my .zshrc file below my zsh source is after the zsh theme attribute.
When I use echo $SHELL I receive: /usr/bin/zsh
This is the theme that is being loaded although the theme set is robbyrussel:
This is the ~/.zshrc file content:
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/daniel/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
you need to delete the .oh-my-zsh using rm -rf .oh-my-zsh and reinstall

Ruby gem tab completion on zsh produces "doubled rest argument definition" error?

When I hit gem push <tab>, it displays this error (regardless of whether the directory contains any .gem files):
_arguments:comparguments:325: doubled rest argument definition: *:gem:_files -g "*.gem(-.)"
_arguments:comparguments:325: doubled rest argument definition: *:gem:_files -g "*.gem(-.)"
_arguments:comparguments:325: doubled rest argument definition: *:gem:_files -g "*.gem(-.)"
I have no idea how to fix this and Google is no help. My fpath:
> echo $fpath
/Users/robenkleene/.zsh/completion
/usr/local/share/zsh/site-functions
/usr/local/Cellar/zsh/5.7/share/zsh/functions
I've tried uninstalling and re-installed Ruby via homebrew because the above "Cellar" path contains a _gem file that I believe defines this completion function, but that didn't work.
Any other ideas? Thanks!
(Also, if anyone has any suggestions of where I might file a bug report for this that would also be helpful, thanks again!)
I hacked together my own terrible solution to this but it's better than nothing.
I copied the _gem file from /usr/local/Cellar/zsh/5.7/share/zsh/functions to /Users/robenkleene/.zsh/completion and then modified the offending line (note that this only works because I have fpath=(~/.zsh/completion $fpath) in my zshrc):
- args+=( '*:gem:_files -g "*.gem(-.)"' )
+ args=( '*:gem:_files -g "*.gem(-.)"' )
So I removed the +. This seems to work, but I'd love a more elegant solution and/or any information about why (based on my Google search), I seem to be the only person experiencing this.
I'm on macOS 10.15.6 running the default zsh 5.7.1. In the default zsh gem completion I found that push is being included in a list of commands which take a remote gem name — and it shouldn't be, it only takes the path to the gem file:
$ gem push --help
Usage: gem push GEM [options]
I applied the following patch to a copy of the file higher in $fpath and it now works for me:
--- /usr/share/zsh/5.7.1/functions/_gem
+++ ~/.zsh/completion.d/_gem
## -56,7 +56,7 ##
check|cleanup|contents|dependency|list|open|pristine|rdoc|uninstall|unpack|update)
args+=( '(--all --skip)*:installed gem:->gems-local' )
;|
- fetch|install|lock|owner|push|search|yank)
+ fetch|install|lock|owner|search|yank)
args+=( '*:gem:->gems-remote' )
;|
cleanup|uninstall)
I'm not sure where to contribute this patch. 😅

How to load zsh/mapfile in ZSH

I have installed zsh version 5.6.2 via brew. I am having trouble loading mapfile module.
adding zmodload zsh/mapfile mapfile gives error ~/.zshrc:15: failed to load module 'mapfile': dlopen(/usr/local/Cellar/zsh/5.6.2_1/lib/mapfile.bundle, 9): image not found
Anyone know how to debug this or a fix ?
To load the zsh/mapfile module, just run
zmodload zsh/mapfile
You can check that it's correctly loaded with:
zmodload
You should then see the following list of loaded modules:
zsh/complete
zsh/main
zsh/mapfile
zsh/parameter
zsh/zle
zsh/zutil
You can then use it, for example, such as:
# Define a file named pp with three lines
echo yay1 >> pp
echo yay2 >> pp
echo yay3 >> pp
# Build the associative array
arr=("${(f#)mapfile[pp]}")
# Show the content
echo $arr[1]
echo $arr[2]
echo $arr[3]
For explanation about the mapfile module see ZSH Gem #22: Accessing and editing files with mapfile.
For details about the Parameter Expansion Flags see the corresponding section in the Zsh documentation.

Set an env var for only the provisioner

I need an environment variable added to the front of $PATH that:
Doesn't last beyond the provisioning run.
Is dependent i.e. something will be installed earlier in the run that is then is available via $PATH, so I can't set it globally as this cookbook says to.
I tried the answer here:
Exec { environment => [ "foo=$bar" ] }
but I get the error Error: All resource specifications require names. When I add a name I get other errors about syntax, for which my fiddling around to fix just gives me other errors (the error Syntax error at '}'; expected '}' is my favourite!)
I've tried using export to set it, but I see: Error: Could not find command 'export'
I've tried using set and setenv too, with similar results. There must be a straightforward way to do this, but I can't find it.
Edit
Just to add, these are the available shells:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/zsh
/usr/bin/zsh
zsh is part of the provisioning, but it could be a requirement of the answer, if needs be.
Added to the front of your path, you want to add your resource default like this I believe:
Exec { environment => "PATH=value:$PATH", }
This could be incorrect, but I do know that it will replace the variables you set, not append to them by default. More details at https://docs.puppetlabs.com/puppet/latest/reference/type.html#exec-attribute-environment
I tried a few ways for this, but the best I found was to use Hiera. I read quite a few blogs on how to set this up with Vagrant too, but this was the best I found.
My project directory layout
Vagrantfile
pp/
manifests/
modules/
data/
hiera.yml
common.yml
Vagrantfile
The relevant part of the Vagrantfile:
config.vm.provision "puppet" do |puppet|
puppet.manifests_path = "pp/manifests"
puppet.module_path = "pp/modules/custom"
puppet.manifest_file = "default.pp"
puppet.hiera_config_path = "pp/data/hiera.yaml"
end
I've no idea yet why there needs to be a hiera.yaml which points to a common.yaml, but that's the way it is.
hiera.yaml
---
:backends:
- yaml
:hierarchy:
- "common"
:yaml:
:datadir: '/vagrant/pp/data'
common.yaml
---
ruby_version: "2.3.0"
ruby_prefix: "/opt/rubies"
...
Then in a manifest
$ruby_version = hiera("ruby_version")
$ruby_prefix = hiera("ruby_prefix")
$ruby_dir_fullpath = "${ruby_prefix}/ruby-${ruby_version}"
Seems like a lot of effort to me, but again, that's the way it is.

Is there a .gemrc.local or equivalent?

Like many people I created a dotfiles repo and am trying extract bits that are not private into their respective dotfiles. I generally have a .whatever.local file loaded if it's present which might contain information I don't want checked into a repository. Rubygems use ~/.gemrc file, but I can't see a way to extract private information out of it into separate file. Does anyone know how this might be done?
In particular I'd like to have the list of sources external to the .gemrc file.
I do not see an equivalent to .local as per v2.4.6 (a recent, but not last version).
The source code of RubyGems states something relevant for what you want to achieve, though. For example, in src/ruby-2.3.0/lib/rubygems/config_file.rb:
##
# Gem::ConfigFile RubyGems options and gem command options from gemrc.
#
# gemrc is a YAML file that uses strings to match gem command arguments and
# symbols to match RubyGems options.
#
# Gem command arguments use a String key that matches the command name and
# +:sources+:: Sets Gem::sources
# +:verbose+:: See #verbose
#
# gemrc files may exist in various locations and are read and merged in
# the following order:
#
# - system wide (/etc/gemrc)
# - per user (~/.gemrc)
# - per environment (gemrc files listed in the GEMRC environment variable)
So you could use the GEMRC environment variable to load extra, private files as well.

Resources