-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Improving go helper #2023
base: dev
Are you sure you want to change the base?
Improving go helper #2023
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
ynh_print_info --message="Downloading goenv..." | ||
git init -q | ||
git remote add origin https://github.com/syndbg/goenv.git | ||
goenv="$(command -v goenv $goenv_install_dir/bin/goenv | grep "$goenv_install_dir/bin/goenv" | head -1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command will fail if goenv is not present. You should something like that instead:
if command -v …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case
yunohost/helpers/helpers.v1.d/ruby
Line 135 in a96cb9b
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)" |
and
yunohost/helpers/helpers.v2.1.d/ruby
Line 77 in a96cb9b
rbenv="$(command -v rbenv $RBENV_INSTALL_DIR/bin/rbenv | grep "$RBENV_INSTALL_DIR/bin/rbenv" | head -1)" |
should not be ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me what's troublesome is : what is it doing in the first place x_X
It looks like this is meant to verify that $RBENV_INSTALL_DIR/bin/rbenv
exists (and maybe is executable) ? Shouldn't we just use something like
rbenv="$RBENV_INSTALL_DIR/bin/rbenv"
if [[ -x "$rbenv" ]]
then
...
else
...
fi
(In fact that was the original code x_x)
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id) | ||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uuuuh not sure why switching to the new version ... the current one with json and jq
seems much more clean and robust ? Is it that the ruby helpers still use an hacky grep ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ruby helper still using grep
yunohost/helpers/helpers.v2.1.d/ruby
Line 231 in f7ed895
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') |
and
yunohost/helpers/helpers.v1.d/ruby
Line 285 in f7ed895
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') |
HOME=$install_dir eval "$(goenv init -)" | ||
export HOME=${HOME:-"/root/"} | ||
eval "$(goenv init -)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would tend to keep the previous syntax such that HOME
doesn't get change in the rest of the script which could have side effect idk ... also we probably want to make sure that HOME is the app's install dir and not /root/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove :
the part :
yunohost/helpers/helpers.v2.1.d/go
Lines 150 to 159 in cd12849
# Set environment for Go users | |
echo "#goenv | |
export GOENV_ROOT=$GOENV_INSTALL_DIR | |
export PATH=\"$GOENV_INSTALL_DIR/bin:$PATH\" | |
eval \"\$(goenv init -)\" | |
#goenv" > /etc/profile.d/goenv.sh | |
# Load the environment | |
export HOME=${HOME:-"/root/"} | |
eval "$(goenv init -)" |
from each helper Go and Ruby; helper 2 and helper2.1
The first part /etc/profile.d/****
is to set the environment variables at startup of the Bash shell. But we don't need go and ruby environment variables set to each users.
The second part eval \"\$(goenv init -)\"
is to initialise environment for current user, but we don't need that either, as all we need is done in _ynh_load_go_in_path_and_other_tweaks
same for ruby
export GOENV_ROOT="$goenv_install_dir" | ||
export goenv_root="$goenv_install_dir" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(are we sure that having that same var in lowercase is actually useful for anything x_x ... i guess it comes from copypasting the same stuff as for ruby but that sounds very meh)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think, it's usefull, but was in ruby helper
# Get the absolute path of this version of go | ||
go_dir="$GOENV_INSTALL_DIR/versions/$app/bin" | ||
# Get the absolute path of this version of Go | ||
go_dir="$GOENV_INSTALL_DIR/versions/$go_version/bin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm super confused because it is $app
for the ruby helper x_X Or is the ruby helper also wrong ? https://github.com/YunoHost/yunohost/blob/dev/helpers/helpers.v2.1.d/ruby#L30
I don't understand what defines the name of these folder ... I assume they are created when calling rbenv install
? X_x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby helper use the alias plugins :
yunohost/helpers/helpers.v2.1.d/ruby
Line 126 in f7ed895
if git remote -v 2> /dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then |
and
yunohost/helpers/helpers.v1.d/ruby
Line 184 in f7ed895
if git remote -v 2> /dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then |
That plugins is not available for goenv, so there is no $app
in $GOENV_INSTALL_DIR/versions/
ynh_print_info --message="Downloading goenv..." | ||
git init -q | ||
git remote add origin https://github.com/syndbg/goenv.git | ||
goenv="$(command -v goenv $goenv_install_dir/bin/goenv | grep "$goenv_install_dir/bin/goenv" | head -1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me what's troublesome is : what is it doing in the first place x_X
It looks like this is meant to verify that $RBENV_INSTALL_DIR/bin/rbenv
exists (and maybe is executable) ? Shouldn't we just use something like
rbenv="$RBENV_INSTALL_DIR/bin/rbenv"
if [[ -x "$rbenv" ]]
then
...
else
...
fi
(In fact that was the original code x_x)
(Now i'm just super confused about what's the best starting point between ruby and go, but it definitely looks like the ruby helper code could use some simplifications too @_@) |
Co-authored-by: Alexandre Aubin <[email protected]>
I don't know either. The point is: Go helper was a copy/pasta of Ruby as experimental helper. |
Hi all, thanks for your work on the matter ! |
The problem
There was some issues and missing parts in the go helper
Solution
Use the Ruby helper as starting point to improve the go helper
PR Status
Ready
How to test
Put it in package like lxd and use it / I can do some test PR to show that it works