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

Plugin named erlang already added #66

Closed
nathany opened this Issue Jun 20, 2016 · 16 comments

Comments

Projects
None yet
5 participants
@nathany

nathany commented Jun 20, 2016

Hi. I've been using asdf for about 4 months now on CircleCI. Today it started giving me this error. Is there anything that changed in asdf that could have caused this, and any suggestions to work around it?

$ asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git
Plugin named erlang already added

asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git returned exit code 1

Action failed: asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git

The code that I'm running looks like this (hasn't changed):

if ! asdf | grep version; then git clone https://github.com/HashNuke/asdf.git ~/.asdf; fi
asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git
asdf plugin-add elixir https://github.com/HashNuke/asdf-elixir.git
erlang_version=$(awk '/erlang/ { print $2 }' .tool-versions) && asdf install erlang ${erlang_version}
elixir_version=$(awk '/elixir/ { print $2 }' .tool-versions) && asdf install elixir ${elixir_version}
...

The directories that I'm caching also hasn't changed:

~/.asdf
~/.asdf/installs/elixir/1.2.6/.mix
deps
_build

I did a clean rebuild (cleared the cache) last week. Not sure if that's related.

@Stratus3D

This comment has been minimized.

Show comment
Hide comment
@Stratus3D

Stratus3D Jun 20, 2016

Member

That is strange. I have not experienced that issue. That error message you got from asdf is only printed when that directory (~/.asdf/plugins/erlang) already exists. Is there a way you can check if that directory exists? If it already exists then that is the problem. Even if the directory is empty asdf will still consider it a fully installed plugin.

Also, in you script I see you extracting versions from the .tool-versions file and then installing them. You shouldn't need to do that. Try doing something like this (untested code):

$(cd dir_with_tool_versions_file && asdf install);

Where dir_with_tool_versions_file is the directory containing the .tool-versions file you want to use. asdf will read the .tool-versions file and install everything that isn't already installed (in your case most likely Erlang and Elixir would be installed).

Member

Stratus3D commented Jun 20, 2016

That is strange. I have not experienced that issue. That error message you got from asdf is only printed when that directory (~/.asdf/plugins/erlang) already exists. Is there a way you can check if that directory exists? If it already exists then that is the problem. Even if the directory is empty asdf will still consider it a fully installed plugin.

Also, in you script I see you extracting versions from the .tool-versions file and then installing them. You shouldn't need to do that. Try doing something like this (untested code):

$(cd dir_with_tool_versions_file && asdf install);

Where dir_with_tool_versions_file is the directory containing the .tool-versions file you want to use. asdf will read the .tool-versions file and install everything that isn't already installed (in your case most likely Erlang and Elixir would be installed).

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 20, 2016

Thanks for the reply. I'm currently caching ~/.asdf and all the directories under it, so that probably explains why it's failing (if the cache exists). It's possible that I was using an older version of asdf for some time, which was working. I guess the solution is to not cache that entire folder from build to build, and just some specific folders under asdf?

Thanks for the .tool-versions tip.The file should already be in the current directory, so that should simplify things.

erlang 18.3
elixir 1.2.6

nathany commented Jun 20, 2016

Thanks for the reply. I'm currently caching ~/.asdf and all the directories under it, so that probably explains why it's failing (if the cache exists). It's possible that I was using an older version of asdf for some time, which was working. I guess the solution is to not cache that entire folder from build to build, and just some specific folders under asdf?

Thanks for the .tool-versions tip.The file should already be in the current directory, so that should simplify things.

erlang 18.3
elixir 1.2.6
@Stratus3D

This comment has been minimized.

Show comment
Hide comment
@Stratus3D

Stratus3D Jun 20, 2016

Member

You could try not caching those directories, but that will slow your build down. Another disadvantage of caching is that you might be using an old version of the Erlang and Elixir plugins, though this may not be an issue, and could be a benefit if things change significantly. Assuming your fine with adding a second or two to your build time, I would probably not cache the plugin dirs and reinstall them for each build.

Member

Stratus3D commented Jun 20, 2016

You could try not caching those directories, but that will slow your build down. Another disadvantage of caching is that you might be using an old version of the Erlang and Elixir plugins, though this may not be an issue, and could be a benefit if things change significantly. Assuming your fine with adding a second or two to your build time, I would probably not cache the plugin dirs and reinstall them for each build.

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 20, 2016

Okay. But it still makes sense to cache ~/.asdf/installs? Any other directories you'd recommend caching?

nathany commented Jun 20, 2016

Okay. But it still makes sense to cache ~/.asdf/installs? Any other directories you'd recommend caching?

@Stratus3D

This comment has been minimized.

Show comment
Hide comment
@Stratus3D

Stratus3D Jun 20, 2016

Member

I'm honestly not sure. I haven't ever used asdf for CI builds before. My guess is that's probably wise (if you upgrade Erlang/Elixir versions the installs would be in different directories so the caching shouldn't interfere).

Member

Stratus3D commented Jun 20, 2016

I'm honestly not sure. I haven't ever used asdf for CI builds before. My guess is that's probably wise (if you upgrade Erlang/Elixir versions the installs would be in different directories so the caching shouldn't interfere).

@Stratus3D

This comment has been minimized.

Show comment
Hide comment
@Stratus3D

Stratus3D Jun 20, 2016

Member

@asdf-vm/maintainers Any thoughts here? I haven't ever used asdf with caching like this. Do you guys see any pitfalls?

Member

Stratus3D commented Jun 20, 2016

@asdf-vm/maintainers Any thoughts here? I haven't ever used asdf with caching like this. Do you guys see any pitfalls?

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 20, 2016

That's okay. I'll probably just remove all caching of the asdf stuff for now and see how it goes. Thanks for your help.

nathany commented Jun 20, 2016

That's okay. I'll probably just remove all caching of the asdf stuff for now and see how it goes. Thanks for your help.

@danhper

This comment has been minimized.

Show comment
Hide comment
@danhper

danhper Jun 21, 2016

Member

@nathany Thanks for the feedback!
Sorry, that's my bad.
I didn't think the behavior was relied on, and thought it would make more sense to exit with 1 was the plugin was not actually added.
You should definitely use your CI cache, at least for ~/.asdf/installs.

For now, could you just try something like this please?

 asdf plugin-list | grep -q erlang || asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git

@asdf-vm/maintainers Do you think it is better to exit with 0 or not when the plugin already existed? As it did not actually add the plugin, a non-zero code makes more sense to me. What do you think?

Member

danhper commented Jun 21, 2016

@nathany Thanks for the feedback!
Sorry, that's my bad.
I didn't think the behavior was relied on, and thought it would make more sense to exit with 1 was the plugin was not actually added.
You should definitely use your CI cache, at least for ~/.asdf/installs.

For now, could you just try something like this please?

 asdf plugin-list | grep -q erlang || asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git

@asdf-vm/maintainers Do you think it is better to exit with 0 or not when the plugin already existed? As it did not actually add the plugin, a non-zero code makes more sense to me. What do you think?

@Stratus3D

This comment has been minimized.

Show comment
Hide comment
@Stratus3D

Stratus3D Jun 21, 2016

Member

Non-zero for skipped installs makes sense to me.

Member

Stratus3D commented Jun 21, 2016

Non-zero for skipped installs makes sense to me.

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 21, 2016

@tuvistavie Thanks, I'll give it a try. Not caching the installs added 10 minutes to my test run.

nathany commented Jun 21, 2016

@tuvistavie Thanks, I'll give it a try. Not caching the installs added 10 minutes to my test run.

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 21, 2016

It's working well. Thanks everyone.

nathany commented Jun 21, 2016

It's working well. Thanks everyone.

@nathany nathany closed this Jun 21, 2016

@HashNuke

This comment has been minimized.

Show comment
Hide comment
@HashNuke

HashNuke Jun 22, 2016

Member

@tuvistavie Non-zero exit for a plugin already installed is very appropriate.

Also @kdisneur's has a blog post about using asdf on CircleCI - https://kevin.disneur.me/archives/2015-06-14-elixir-on-circleci.html

Member

HashNuke commented Jun 22, 2016

@tuvistavie Non-zero exit for a plugin already installed is very appropriate.

Also @kdisneur's has a blog post about using asdf on CircleCI - https://kevin.disneur.me/archives/2015-06-14-elixir-on-circleci.html

@danhper

This comment has been minimized.

Show comment
Hide comment
@danhper

danhper Jun 22, 2016

Member

I just sent a message to @kdisneur on Twitter to ask him if he could update his blog with the above check!

https://twitter.com/tuvistavie/status/745473152101191681
https://twitter.com/tuvistavie/status/745473287908536321

Member

danhper commented Jun 22, 2016

I just sent a message to @kdisneur on Twitter to ask him if he could update his blog with the above check!

https://twitter.com/tuvistavie/status/745473152101191681
https://twitter.com/tuvistavie/status/745473287908536321

@kdisneur

This comment has been minimized.

Show comment
Hide comment
@kdisneur

kdisneur Jun 22, 2016

Contributor

Thanks @tuvistavie, I forgot to update the blog post when this change was released.

Mistake fixed, should be all good now 👍

Contributor

kdisneur commented Jun 22, 2016

Thanks @tuvistavie, I forgot to update the blog post when this change was released.

Mistake fixed, should be all good now 👍

@danhper

This comment has been minimized.

Show comment
Hide comment
@danhper

danhper Jun 22, 2016

Member

@kdisneur Thank you very much! 😄

Member

danhper commented Jun 22, 2016

@kdisneur Thank you very much! 😄

@nathany

This comment has been minimized.

Show comment
Hide comment
@nathany

nathany Jun 22, 2016

Thanks @kdisneur. For comparison, this is my current circle.yml. It's pretty similar:

machine:
  environment:
    PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"

dependencies:
  cache_directories:
    - ~/.asdf
    - deps
    - _build
  override:
    - if ! asdf | grep version; then git clone https://github.com/HashNuke/asdf.git ~/.asdf; fi
    - asdf plugin-list | grep -q erlang || asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git
    - asdf plugin-list | grep -q elixir || asdf plugin-add elixir https://github.com/HashNuke/asdf-elixir.git
    - asdf install
    - mix local.hex --force
    - mix local.rebar --force
    - mix deps.get
    - mix deps.compile
test:
  override:
    - MIX_ENV=test mix do compile --warnings-as-errors, test --include remote

nathany commented Jun 22, 2016

Thanks @kdisneur. For comparison, this is my current circle.yml. It's pretty similar:

machine:
  environment:
    PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"

dependencies:
  cache_directories:
    - ~/.asdf
    - deps
    - _build
  override:
    - if ! asdf | grep version; then git clone https://github.com/HashNuke/asdf.git ~/.asdf; fi
    - asdf plugin-list | grep -q erlang || asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git
    - asdf plugin-list | grep -q elixir || asdf plugin-add elixir https://github.com/HashNuke/asdf-elixir.git
    - asdf install
    - mix local.hex --force
    - mix local.rebar --force
    - mix deps.get
    - mix deps.compile
test:
  override:
    - MIX_ENV=test mix do compile --warnings-as-errors, test --include remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment