asdf command no longer works inside tmux session - tmux

After upgrading to osx Monterey and updating brew, the asdf command stopped working inside a tmux session. I'm only using asdf to manage Node.js and Elixir versions.
$ asdf
Unknown command: asdf
/usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf: line 82: /usr/local/opt/asdf/lib/commands/command-help.bash: No such file or directory
When I run a tmux session, the asdf command produces the error above. However, the asdf command runs correctly when I don't use tmux.
When I run which asdf from a tmux session, I should get a path to the asdf executable. Instead I get this:
$ which asdf
asdf () {
local command
command="$1"
if [ "$#" -gt 0 ]
then
shift
fi
case "$command" in
("shell") eval "$(asdf export-shell-version sh "$#")" ;;
(*) command asdf "$command" "$#" ;;
esac
}

The fix for this issue was to Uninstall asdf with brew:
brew uninstall asdf
Then, use the suggested git based installation instead of brew:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1
It looks like the brew based installation causes problems when running asdf inside a tmux session. Im not sure if this is in fact a osx Monterey issue, or simply an issue of using brew to update to the latest version of asdf. Regardless, this is how to get asdf working inside your tmux sessions again.

After opening an issue on the HomeBrew repo, Tmux no longer works with asdf. The problem was: "a cache invalidation problem." I was able to resolve this issue by killing all tmux sessions, as recommended by the one of the helpful #homebrew
tmux kill-server
This resolved the problem.

Related

How to compile rsync on MacOS and install it (not using brew)?

As sometime I am trying to compile a full version (with all options) of rsync on MacOS (please, do not ask why I want to do it - if you can help me clear and directly, thank you so much. Otherwise, do not waste your time).
I found a really helpful script made by "junsionzhang" (https://gist.github.com/junsionzhang), which in my option is simple and direct. Thank you junsionzhang!
Even being a good script, clear, step-by-step, there are some steps that does not work for me (and I tried a lot and for a while).
Here is the script (at Oct, 16, 2022):
#Compile rsync 3.0.7
#Follow these instructions in Terminal on both the client and server to download and compile rsync 3.0.7:
#Download and unarchive rsync and its patches
cd ~/Desktop
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-3.1.2.tar.gz
tar -xzvf rsync-3.1.2.tar.gz
rm rsync-3.1.2.tar.gz
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-patches-3.1.2.tar.gz
tar -xzvf rsync-patches-3.1.2.tar.gz
rm rsync-patches-3.1.2.tar.gz
cd rsync-3.1.2
#Apply patches relevant to preserving Mac OS X metadata
patch -p1 <patches/fileflags.diff
patch -p1 <patches/crtimes.diff
patch -p1 <patches/hfs-compression.diff
#Configure, make, install
./prepare-source
./configure
make
sudo make install
#Verify your installation
/usr/local/bin/rsync --version
#By default, rsync will be installed in /usr/local/bin.
#If that isn't in your path, you will need to call your new version of rsync by its absolute path (/usr/local/bin/rsync).
The three patches lines does not work for me. After patching the fileflags, the rsync patched can not me "prepared", and of course, not be configured. The others, crtimes.diff and hfs-compression.diff, does not exist on the TAR package.
So, questions:
Trying to compile the 3.2.6 version os MacOS Big Sur (11.7), what do I need and which is the right/correct way and steps to patch, update and have the "correct"version?
How do I (correctly) compile and install the all the libraries to have a real full rsync version, with all features available (ACL support, Xattr support, xxhash, zstd, lz4, openssl crypto, and so on...)?
I would like to update and contribute to a new "junsionzhang" script version, making options to install a simple/standard version (rsync only) and options to install the libraries and choose for a "more complete" version, and help another Mac users and the community. How can I make this bash script?
How to install gawk, mawk, nawk, awk ( and where from (what are the differences): gawk, mawk, nawk?
Some libraries I already have installed (which I do not know if I did them right) seems to be outdated. How to I update them?
When running "./prepare-source", i get this: "make: Nothing to be done for `conf'.". Does this is right?
Thank you all! I really appreciate for all help I can get!
Completely untested (I don't run MacOS).
URLs to access the source code:
Source Version Tarballs: https://rsync.samba.org/ftp/rsync/src/
Git repository: https://github.com/WayneD/rsync
might need these pre-requisites (from INSTALL.md):
brew install automake
brew install xxhash
brew install zstd
brew install lz4
brew install openssl
code to download and extract (to ~/Desktop/rsync-3.2.6):
# Download the relevant version of Rsync and the same version of
# Rsync patches, extract them and apply the "suggested"
# patches from the original script:
cd ~/Desktop
# Rsync
curl -O https://rsync.samba.org/ftp/rsync/src/rsync-3.2.6.tar.gz
tar -xzvf rsync-3.2.6.tar.gz
rm rsync-3.2.6.tar.gz
# Patches
curl -O https://rsync.samba.org/ftp/rsync/src/rsync-patches-3.2.6.tar.gz
tar -xzvf rsync-patches-3.2.6.tar.gz
rm rsync-patches-3.2.6.tar.gz
apply the "suggested" patches, light the blue touch paper and stand back:
cd ~/Desktop/rsync-3.2.6
# Apply patches relevant to preserving Mac OS X metadata
patch -p1 <patches/fileflags.diff
patch -p1 <patches/crtimes.diff
patch -p1 <patches/hfs-compression.diff
# Configure, make, install
./prepare-source
./configure
make
sudo make install
# Verify your installation
/usr/local/bin/rsync --version

Why can't zsh execute command compdef?

I have installed zsh and oh my zsh on Ubuntu 18.04. I would like to use autocompletion for kubectl. Therefore I have added source <(kubectl completion zsh) to my ~/.zshrc file.
On execution of this script zsh gets the following error:
complete:13: command not found: compdef
The kubectl documentation states that when one gets the error above, you should put the following on top of the .zshrc file:
autoload -Uz compinit
compinit
After doing this and restarting the terminal, I get the same error.
In a git-issue I found the following helped people with a common issue:
#This will perform chmod g-w for each file returned by compaudit to remove write access for group
compaudit | xargs -I % chmod g-w "%"
#This will perform chown to current user (Windows and Linux) for each file returned by compaudit
compaudit | xargs -I % chown $USER "%"
#Remove all dump files (which normally speed up initialization)
rm ~/.zcompdump*
#Regenerate completions file
compinit
zsh logs the following while running the script:
kubescript:12457: command not found: _bash_comp
Unfortunately this did not solve my problem. What else can I do to fix my issue? Or even still: what can I do to find out what is causing it?
I fixed the error by using the following code in .zshrc:
# K8s auto-complete
autoload -U +X compinit && compinit
source <(kubectl completion zsh)
You may also do it using oh-my-zsh plugin if you use oh-my-zsh.
I had the same issue and it was solved updating nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For my OSX 10.15.7 I did something similar
vi ~/.zshrc
alias k=kubectl
autoload -U +X compinit && compinit
[[ /usr/local/bin/kubectl ]] && source <(kubectl completion zsh)
Works like a charm!
I encountered this after installing the Angular CLI. Turns that Angular adds something into your .zshrc file.
If you recently installed Angular CLI, open ~/.zshrc and remove the lines added by Angular CLI.
After trying lot of options and going through diff treads. It worked for me after running below command
autoload -Uz compinstall && compinstall
This configures the ~/.zshrc and initialize the compinit by adding these 2 below lines:
autoload -Uz compinit
compinit
and then run below sudo commands which mentioned in link
$ sudo chmod -R 755 /usr/local/share/zsh
$ sudo chown -R root:staff /usr/local/share/zsh
$ compaudit | xargs chmod g-w
at last restart the terminal.
Hope this helps for someone.
In my case the issue was fixed after re-installing oh-my-zsh:
Deleted my old version rm -rf ~/.oh-my-zsh
Installed from https://github.com/ohmyzsh/ohmyzsh
I really tried every answer here, but nothing worked.
So, I tried this tutorial paying attention to the last observation:
"Note: Make sure you add this snippet before any call to compdef else you will still see the error"
I had a complete call from Terraform installation in my ~/.zshrc and ~/.bash_profile files.
https://thysmichels.com/2020/07/16/mac-solved-command-not-found-compdef/
For me I had this line:
source ~/.oh-my-zsh/plugins/git/git.plugin.zsh
In my ~/.zshrc file. Which was trying to source the plugin before it is loaded by plugins=(git)
Removing that line fixed it for me.
If you have added the plugins and everything works well, One of the reasons is you may be trying to use the plugin before it is loaded. As in my case.
This issue is (also) faced after installing Angular CLI (Angular Version 14.x) and accepting addition of autocompletion for the cli commands. Snippet from .zshrc:
# Load Angular CLI autocompletion.
source <(ng completion script)
Commenting out the source line resolved the issue for me (macOS 12.6 (21G115)).
# Load Angular CLI autocompletion.
# source <(ng completion script)
Still need to work out the root cause.

Getting libevent error when running installing tmux

configure: error: "libevent not found" when installing tmux
I downloaded the tmux tarball and trying to install it. I cannot connect to git on the server i am trying to install. This for a new Red Hat Enterprise Linux Server release 6.5 (Santiago) server.
I am new to Linux and never did installation as a root :)
[tmux-master]# ./configure && make
...
configure: error: "libevent not found"
Can you please suggest me how to get it working?
tmux depends on libevent. If you are using RHEL there is a libevent-devel package you can install.
But I think on RHEL6.5 it is libevent 1.4 which is very old (you normally need 2.x). 1.4 will still work with tmux but you need to make this change in tmux's control.c around line 79:
- line = evbuffer_readln(c->stdin_data, NULL, EVBUFFER_EOL_LF);
+ /* line = evbuffer_readln(c->stdin_data, NULL, EVBUFFER_EOL_LF); */
Another option is to build libevent 2.x yourself but that is probably more complicated for you.
I fixed the issue by using an alias as mentioned in the below link:
https://unix.stackexchange.com/questions/17907/why-cant-gcc-find-libevent-when-building-tmux-from-source/17918
Really, the real answer to this question is installing event2 with yum.
Use the following two commands--one erase, and then install:
sudo yum erase libevent-devel
sudo yum install libevent2-devel
TMUX should work after this.
If you want to keep the older version for consistency sake, you should not use the first (erase) command.

Zsh Docker Plugin not Working

I have been using oh-my-zsh for a while now and the docker plugin as recently stopped working for me for some reason.
I checked my ~/.zshrc file and the plugin is included
plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting docker)
I checked the ~/.oh-my-zsh/plugins/docker directory and there is a _docker file in there. Yet when I type docker and press Tab, I get none of the autocomplete shortcuts that I used to get.
I can confirm that my git plugin works just fine but not the docker plugin. Tried doing exec zsh and source ~/.zshrc and restarted my terminal but no luck.
Am I missing something?
You might want to try and remove any .zcompdump-(...) files you may have on your user's home directory - using something like rm ~/.zcompdump* on a terminal, or some file browser - and then reload the .zschrc file with the command source ~/.zshrc or restart the terminal - whichever works best for you. See this
Then see if it works.
It seems oh-my-zsh is not loading plugins/docker/_docker file. You must add it to ~/.zshrc in an another way.
Add these lines to your ~/.zshrc file:
fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit
For me it was simply the case that I needed to launch Docker for the first time from spotlight on my Mac in order for Docker for Desktop to get the access it needed. Then the docker version command worked just fine.
Follow these steps if you are using oh-my-zsh and autocomplete is not working:
Make the following three links:
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
Either add autoload -Uz compinit; compinit to .zshrc or run in your shell:
echo "autoload -Uz compinit; compinit" >> .zshrc
In my case: Windows 10 + WSL2 + Hyper
I was having this error because I stopped Docker on Windows... Starting it again makes the error disappear in Hyper (thus, also in ZSH).
No .zshrc changes or additional commands to add inside.
#youhans's solution worked for me permanently. You might have permission issue to make needed adjustment on "zshrc". I have changed the permission to "read and write" and added the code snippet from #youhans's response to the end of "zshrc" file. Now completion system always works.
Before I had to type below snippet in command line whenever open a new terminal.
autoload -Uz compinit && compinit
In my case it occurred because of an alias. I had defined alias docker=docker.exe.
Removing that did it work again.
System & Environment
O.S.: Windows 10 Home, x64
Shell: Zsh (on Gitbash)
I think you may be missing ,'s in between each plugin.
plugins=(git, colored-man, colorize, github, jira, vagrant, virtualenv, pip, python, brew, osx, zsh-syntax-highlighting, docker)
Alternatively you can place each plugin on a separate line:
plugins=(
git
colored-man
colorize
github
jira
vagrant
virtualenv
pip
python
brew
osx
zsh-syntax-highlighting
docker
)

How to automatically update R to the latest patched version?

Is there any way to automatically update R on Mac OS X to the latest patched version (R-Patched) on a daily basis or some predetermined intervals?
My impression is that compiling from source is the most (only?) reliable way to get the most recent patched version, but I could be wrong about this. A simple shell script to download the latest patched version and recompile would be:
curl -o /tmp/R-patched.tar.gz ftp://ftp.stat.math.ethz.ch/Software/R/R-patched.tar.gz
tar xzvf /tmp/R-patched.tar.gz
cd /tmp/R-patched
./configure
make
cp bin/R <old_R_binary_location>
You could then use crontab to run this at regular intervals. I don't find the crontab man page to be very helpful, so I always end up referring back to guides such as this one.
I have a bash script that installs the daily patched build from http://r.research.att.com. Installed libraries remain untouched, except for those in core.
I update manually, but you could set up a cron job as #bnaul suggests. I'm not sure how it will handle the need for sudo'ing, however. You might have to move your R out of /Library/Frameworks and then change the script accordingly.
#!/bin/bash
curl -s http://r.research.att.com/R-2.13-branch-leopard-universal.tar.gz | sudo tar fvxz - -C /

Resources