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

Plugin named erlang already added #66

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

Plugin named erlang already added #66

nathany opened this issue Jun 20, 2016 · 16 comments

Comments

@nathany
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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.

@nathany
Copy link
Author

nathany commented Jun 20, 2016

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

@Stratus3D
Copy link
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).

@Stratus3D
Copy link
Member

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

@nathany
Copy link
Author

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
Copy link
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
Copy link
Member

Non-zero for skipped installs makes sense to me.

@nathany
Copy link
Author

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
Copy link
Author

nathany commented Jun 21, 2016

It's working well. Thanks everyone.

@nathany nathany closed this as completed Jun 21, 2016
@HashNuke
Copy link
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

@danhper
Copy link
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
Copy link
Contributor

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

Mistake fixed, should be all good now 👍

@danhper
Copy link
Member

danhper commented Jun 22, 2016

@kdisneur Thank you very much! 😄

@nathany
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants