Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wrapper compatible with the zsh shell - Mac OS Big Sur 11.2 #17

Open
dr563105 opened this issue Feb 14, 2021 · 10 comments
Open

Make wrapper compatible with the zsh shell - Mac OS Big Sur 11.2 #17

dr563105 opened this issue Feb 14, 2021 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dr563105
Copy link

dr563105 commented Feb 14, 2021

Hi!

Thanks for this wrapper. I became aware of this wrapper from one of the ROS Answers posts when I was looking for help with conda and ROS.

I have been running into a few problems. I would appreciate any help you can provide.

System: Mac OS Big Sur 11.2. M1 ARM macbook.
Shell: echo $SHELL - /bin/zsh
Conda version: Miniforge, v4.9.2
Python version inside conda env: 3.8
ROS version and distribution: ROS2 Foxy. Workspace is inside $HOME directory.

Since the shell is zsh and the code uses bash, I simply changed the occurrences of bash to zsh in scripts install.sh and ros_conda_wrapper_rc. Please correct me if it is not as simple as renaming.

(base) ➜  .ros_conda_wrapper git:(master) ✗ sh install.sh 
-- Installing the ROS Conda wrapper --
ROS Conda wrapper file added to your home directory.
A backup will be made to: /Users/dross/.zshrc-ros_conda_wrapper.bak
sed: illegal option -- -
usage: sed script [-Ealnru] [-i extension] [file ...]
	sed [-Ealnu] [-i extension] [-e script] ... [-f script_file] ... [file ...]
ros_conda_wrapper_rc file source command installed to your .zshrc file.
Ros Conda wrapper successfully installed.
For this change to become active, you have to open a new terminal.

Note: I have already initialised the Conda environment and added the conda init command to .zshrc.

My .zshrc now has these lines -

# >>> ros_conda_wrapper initialize >>>
if [ -f "/Users/dross/.ros_conda_wrapper_rc" ]; then
    . "/Users/dross/.ros_conda_wrapper_rc"
fi
# <<< ros_conda_wrapper initialize <<<

And instead of .zprofile, .bash_profile has these lines -

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/homebrew/Caskroom/miniforge/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/homebrew/Caskroom/miniforge/base/etc/profile.d/conda.sh" ]; then
        . "/opt/homebrew/Caskroom/miniforge/base/etc/profile.d/conda.sh"
    else
        export PATH="/opt/homebrew/Caskroom/miniforge/base/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Upon opening a new shell, I get this -

**_ros_conda_main:31: command not found: dirname
_ros_conda_main:32: command not found: dirname**
WARNING: It appears that anaconda was not initiated before this wrapper was sourced. Please make sure anaconda is initiated in your .zshrc file before running the ros_conda_wrapper.
(base) ➜  ~ 

In fact, some general commands don't work -

zsh: command not found: ls
(base) ➜  ~ vim
zsh: command not found: nvim
(base) ➜  ~ time
shell  0.13s user 0.11s system 0% cpu 5:11.10 total
children  0.34s user 0.15s system 0% cpu 5:11.10 total
(base) ➜  ~ conda --version
__add_sys_prefix_to_path:6: command not found: dirname
__add_sys_prefix_to_path:7: command not found: dirname
conda 4.9.2

Since the script fails here, --ros-wrapper argument doesn't work. The consequent steps to activate and initialise with a conda env are also unsuccessful.

Can you please help?

Also, in my limited hacking of your script I saw that wrapper works even with ROS2. Is this correct?
I use ROS2 Foxy, built from source as instructed here.
If not, what further steps should I need to make it work?

Thank you.

@rickstaa rickstaa added the enhancement New feature or request label Feb 15, 2021
@rickstaa
Copy link
Owner

@dr563105 Thanks for your interest in my script. Thanks a lot for bringing this to my attention. I haven't tested the script on Mac/ ROS2 or the zsh shell. I am therefore not aware of the problems that will occur when using the script in this new environment. I was hoping the ROS team solved the Conda conflicts in version 2, but apparently, they are still present. This is unfortunate because a big part of the scientific community uses Conda as their package manager.

I am currently working on my Master Thesis and am therefore a bit short on time. However, I will try to perform some tests this weekend to discuss a possible solution. Judging from this StackOverflow post the difference between the two shells is small, so it might not be had to get it to work.

@rickstaa rickstaa self-assigned this Feb 15, 2021
@dr563105
Copy link
Author

dr563105 commented Feb 15, 2021

I was hoping the ROS team solved the Conda conflicts in version 2, but apparently, they are still present.

I can't say for sure that it doesn't work. It might just be me. Since the M1 Mac ARM architecture is new, I built it from source and the ROS2 workspace is in the home directory.

I am currently working on my Master Thesis and am therefore a bit short on time.

I know how it is. I'm not good at scripting. Otherwise I would myself try to fix it.

If you need more detailed steps to reproduce the issue, let me know please.

@rickstaa
Copy link
Owner

rickstaa commented Feb 19, 2021

@dr563105 Just a quick heads up. The Robostaxk team just released the ros-noetic desktop version. If ros-noetic contains all the packages you need, it might be the easiest way to use ROS under Conda (see https://medium.com/robostack/cross-platform-conda-packages-for-ros-fa1974fd1de3). Their packages are used under the hood for initiating ROS inside the wrapper. If it does not contain all the packages you need and want to use the desktop ROS version while also having Coda installed, the wrapper is required. I planned some time to take a look at the. Mac compatibility of the wrapper next week.

@dr563105
Copy link
Author

Thanks. I became aware of Robostack release when I was looking for help with conda and ROS. Unfortunately for now my focus is ROS2.

Though it might be tedious, I'm planning to install tensorflow outside conda env.

I planned some time to take a look at the. Mac compatibility of the wrapper next week.

no problem. Take your time.

@rickstaa
Copy link
Owner

rickstaa commented Apr 22, 2021

@dr563105 I quickly looked at your problem and the first conclusion I found is that the install.sh script does not work for the zsh shell as it should install the workaround inside the .zshrc file instead of the .bashrc file. I think the easiest way to solve this is to create a new zsh branch and update the install script. After that, we can replace the bash commands that are not available in zsh with equivalent commands. Did you already look at which commands besides dirname should be replaced?

@rickstaa
Copy link
Owner

rickstaa commented Apr 22, 2021

@dr563105 I fixed the dirname issue by replacing it with a zsh equivalent. After this however other errors greeted me. I, unfortunately, do not have enough time to do a full translation of the warpper to the zsh shell. Your welcome to create a pull request if you steel need this feature.

@rickstaa rickstaa changed the title Install in Mac OS Big Sur - Zsh shell Make warpper compatible with the zsh shell - Mac OS Big Sur 11.2 Apr 22, 2021
@rickstaa rickstaa changed the title Make warpper compatible with the zsh shell - Mac OS Big Sur 11.2 Make wrapper compatible with the zsh shell - Mac OS Big Sur 11.2 Apr 22, 2021
@rickstaa rickstaa added the help wanted Extra attention is needed label Apr 22, 2021
@rickstaa rickstaa removed their assignment Apr 22, 2021
@dr563105
Copy link
Author

Hey!
Thanks for the update. Apart from initial renaming and manually adding entries to .zprofile, I don't think I looked further. The main hurdle is learning to script. Otherwise I would attempt myself. I also don't have time now but I will try in the next weeks if I can manage something. I will keep you updated if I find any.

@rickstaa
Copy link
Owner

rickstaa commented Apr 22, 2021

@dr563105 The script is a bit over-complicated on some parts since I tried to make it compatible with multiple bash and Conda version. I think there are some parts I can simplify so that it is easier to understand. Apart from that, I am happy to explain any parts of the script that are unclear and debug together with you if you get stuck.

@dr563105
Copy link
Author

Alright. Your help will be welcome. I will try my best in the coming weeks.

@rickstaa
Copy link
Owner

@dr563105 Don't feel pressured to complete this feature, but please feel free to ask me anything if you decide you want to. I will clean up the code a bit starting next week. Then we know for sure that there is no redundant code.

Repository owner deleted a comment Dec 30, 2023
Repository owner deleted a comment Dec 30, 2023
Repository owner deleted a comment Dec 30, 2023
Repository owner deleted a comment Jan 28, 2024
Repository owner deleted a comment from pavana21 Feb 23, 2024
Repository owner deleted a comment from pavana21 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants