prettify_json.rb not working from command line in zsh - ruby

I keep getting Command Not Found: prettify_json.rb from the command line. I'm using zsh and rvm so, I'm not sure if it has something to do with the paths setting in my .zshrc. I've compared it to some other questions here with similar problems and I'm not able to see an issue.
here is the .zshrc file:
ZSH=$HOME/.oh-my-zsh
alias vi="vim"
source $ZSH/oh-my-zsh.sh
source ~/.git-flow-completion.zsh
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH=/usr/local/bin:$PATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

The json gem may not have shipped with prettify_json.rb. But it is available in the json-utils gem. Try gem install json-utils

Related

update .bashrc file to locate opencv libraries

I am not a sudo user in a server and want to use my version of opencv.
There is .bashrc file for each user. I too have it. Please tell how to set path of local installation of opencv into .bashrc.
Each time I set path in .bashrc and do source ~/.bashrc. And check the version, its still the same.
Make sure you're adding the correct path and that you're appending it at the end of $PATH (i.e. export PATH=$PATH:/path/to/opencv).
Then do a source ~/.bashrc and verify what path is being used using which opencv.

Remove vendor/bundle directory from git

I have been using rbenv for ruby for a while, and I have not had a problem with files being tracked; everything seems to be in it's place, and I haven't really had an issue.
I recently switched to rvm for a new project, and had to change a couple things to my environment. As a result, whenever I now run bundle, all of the gems that were added to my project become tracked via git looking something like this;
new file: vendor/bundle/ruby/2.2.0/bin/aws-rb
new file: vendor/bundle/ruby/2.2.0/bin/byebug
new file: vendor/bundle/ruby/2.2.0/bin/erubis
new file: vendor/bundle/ruby/2.2.0/bin/geocode
new file: vendor/bundle/ruby/2.2.0/bin/nokogiri
new file: vendor/bundle/ruby/2.2.0/bin/rackup
new file: vendor/bundle/ruby/2.2.0/bin/rails
new file: vendor/bundle/ruby/2.2.0/bin/rake
new file: vendor/bundle/ruby/2.2.0/bin/rdoc
new file: vendor/bundle/ruby/2.2.0/bin/ri
new file: vendor/bundle/ruby/2.2.0/bin/sass
new file: vendor/bundle/ruby/2.2.0/bin/sass-convert
new file: vendor/bundle/ruby/2.2.0/bin/scss
new file: vendor/bundle/ruby/2.2.0/bin/sdoc
new file: vendor/bundle/ruby/2.2.0/bin/sdoc-merge
new file: vendor/bundle/ruby/2.2.0/bin/spring
new file: vendor/bundle/ruby/2.2.0/bin/sprockets
new file: vendor/bundle/ruby/2.2.0/bin/thor
new file: vendor/bundle/ruby/2.2.0/bin/tilt
new file: vendor/bundle/ruby/2.2.0/bin/unicorn
new file: vendor/bundle/ruby/2.2.0/bin/unicorn_rails
new file: vendor/bundle/ruby/2.2.0/cache/actionmailer-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/actionpack-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/actionview-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/activejob-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/activemodel-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/activerecord-4.2.6.gem
new file: vendor/bundle/ruby/2.2.0/cache/activesupport-4.2.6.gem
and because of this, github doesn't display the entirety of my commits, my git add's take forever, overall it's just very messy.
With rbenv I did not have this problem, so I can only assume it's something to do with how I set up rvm. Here's my current bash_profile
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
# RBENV - add bin and shims to path
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
# Bash completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Git completion
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
# Aliases
alias b="bundle exec"
alias t="RAILS_ENV=test"
alias bi="bundle install; rbenv rehash"
alias bu="bundle update; rbenv rehash"
# message from RVM (5/2/16)
# first attempt below
#source /Users/username/.rvm/scripts/rvm
# next attempt below
source ~/.rvm/scripts/rvm
I believe this current tracking is due to how my path's are set up, and that is something I do not know too much about currently.
I was wondering if anyone has had some experience with this, if they could tell me how I could stop all of the gems I download from being tracked by git. Any help would be appreciated :)
here's my .bundle/config file
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: true
here's the output of rvm env
export PATH="/Users/username/.rvm/gems/ruby-2.2.3/bin:/Users/username/.rvm/gems/ruby-2.2.3#global/bin:/Users/username/.rvm/rubies/ruby-2.2.3/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.2.3'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.2.3:/Users/username/.rvm/gems/ruby-2.2.3#global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.2.3'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.2.3/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.2.3'
here's the output of which ruby
/Users/username/.rvm/rubies/ruby-2.2.3/bin/ruby
You have to remove .bundle/config (It's a per project configuration that overrides your user preferences).
Ensure you are using right Ruby's version ($rvm list rubies will show your current Ruby version used in this current path)
If you're using the required Ruby version for the project then you should have installed bundler gem for this Ruby version and it should be work.
You should add a .gitignore file.

Cannot set $GOPATH on Mac OSX

I'm trying to set my $GOPATH variable to run some example code on my machine:
$ smitego-example go run main.go
main.go:5:2: cannot find package "github.com/#GITHUB_USERNAME#/smitego" in any of:
/usr/local/go/src/pkg/github.com/#GITHUB_USERNAME#/smitego (from $GOROOT)
($GOPATH not set)
$ smitego-example export $GOPATH=$HOME
-bash: export: `=/Users/#OSX_USERNAME#': not a valid identifier
Contents of github.com/#GITHUB_USERNAME#/smitego/smitego.go:
package smitego
How can I set my GOPATH so it works always and forever?
Update, as of Go 1.8: If you're installing Go 1.8 (released: Feb 2017) or later, GOPATH is automatically determined by the Go toolchain for you.
It defaults to $HOME/go on macOS (nee OS X) - e.g. /Users/matt/go/. This makes getting started with Go even easier, and you can go get <package> right after installing Go.
For the shell: (the manual method)
~/.bash_profile should contain export GOPATH=$HOME/go and also export PATH=$GOPATH/bin:$PATH. The use of the $ is important: make sure to note where I've used it (and where I have not).
For Sublime Text:
Sublime Text menu > Preferences > Package Settings > GoSublime > Settings: User
{
"shell": ["/bin/bash"],
"env": {"GOPATH": "/Users/#USERNAME#/go/"},
}
Make sure your GOPATH is not set to the full path of the package; just the root of your go folder where src, pkg, and bin reside. If you're not using GoSublime, I'd suggest installing that first.
The accepted answer didn't work for me. I investigated and found the cause: I am using zsh, not bash.
I need to add the following two lines to ~/.zshrc:
export GOPATH=/Users/username/go
export PATH=$GOPATH/bin:$PATH
You don't put the $ prefix on a variable when you're assigning it, only when you're reading it.
export GOPATH=$HOME
To make this permanent, put the command in your .bash_profile.
That will work for Terminal shells. If you need to set environment variables that will affect GUI applications, see Environment variables in Mac OS X
Download and install Go tools
https://golang.org/doc/install
Setup Go workspace
mkdir $HOME/go && cd $HOME/go
mkdir bin pkg src
Setup Go environment
sudo vi ~/.bash_profile
export GOPATH=$HOME/go
PATH=$PATH:$GOPATH/bin
Test by creating, building and running a Go project
mkdir -p $GOPATH/src/github.com/todsul/hello
touch $GOPATH/src/github.com/todsul/hello/hello.go
go install
hello
The http://www.golang-book.com/guides/machine_setup#osx
only has instructions for setting the path on ~/.bashrc, not ~/.bash_profile which thanks to this thread was able to get my example file to build.
export GOPATH=$HOME
export PATH=$PATH:$GOPATH/bin
Other Mac users need to add the above to their ~/.bash_profile.
After installing go with brew or with package this solved my problem:
export GOROOT="/usr/local/go"
export GOPATH="$HOME/Documents/goWorkSpace"
export PATH="$HOME/Documents/goWorkSpace/bin:$PATH"
on macOS High Sierra Version 10.3.3, Go[go version go1.10.1 darwin/amd64] Installed here :
Added following on :~/.bashrc
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
and then Go Works
People working with the latest macs and above Catalina version,
you guys need to update the .zshrc file instead of .bash.
Add the following two lines to ~/.zshrc:
export GOPATH=/Users/username/go
export PATH=$GOPATH/bin:$PATH
it should work.!!
This got change a while back, please refer to the link below to understand why .zshrc and not .bash_profile
https://eshop.macsales.com/blog/56921-moving-from-bash-to-zsh-terminal-changes-in-macos-catalina/

How do I get rbenv and textmate to work together?

I tried to trouble-shoot this problem, and found "Configure Textmate 2 for rbenv".
However, when I try implementing the solution using multiple versions of Textmate Shell variables:
version1 of PATH= $PATH:$HOME/.rbenv/bin
version2 of PATH= $HOME/.rbenv/bin:$PATH
version3 of PATH= $PATH:$HOME/.rbenv/bin:/usr/local/bin
TM_RUBY= /usr/local/opt/rbenv/shims/ruby
I get the following error:
env: ruby: No such file or directory
I installed rbenv with brew and which rbenv
gives:
/usr/local/bin/rbenv
which ruby gives:
/usr/local/opt/rbenv/shims/ruby
I have a require in my code, if that changes things. I was told it might.
What shell variables are recommended? What added information would be helpful?
I found my solution:
PATH= $PATH:$HOME/.rbenv/bin
TM_RUBY= /usr/local/opt/rbenv/shims/ruby
PATH = /opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
an interesting note, when the previous posted Path was incorrect, I could not create new files in textmate.

Ruby bundle open, set $EDITOR

I am trying to use the command line to open the the jquery-rails gem. I am using the command: bundle open jquery-rails and I am getting the message returned: To open a bundled gem, set $EDITOR or $BUNDLE_EDITOR
Forgive me if this is totally newb, but how do I set my text editor Notepad++ like the message is telling me to? I am using windows vista/Rails 3.1
Thanks for any advice.
vi ~/.bashrc or ~/.zshrc or whatever you have:
export EDITOR=vim
Because you mentioned Notepad++ I suppose you are working with Windows. You need to set an environment variable called EDITOR containing the path to Notepad++.
If you use zsh on Mac OS X,add this line of code into .zshrc file:
export EDITOR="mvim"
That will make macvim to open the gem.
don't forget to reload your bash session after setting export EDITOR="vim" in ~/bashrc

Resources