JuliaLang / devcontainer-features

Julia Development Container Feature
16 stars 4 forks source link

Error during creation #17

Open 3f6a opened 3 months ago

3f6a commented 3 months ago

I get the following error during creation of a fresh dev container:

Running the postCreateCommand from Feature 'ghcr.io/julialang/devcontainer-features/julia:1'...

[11384 ms] Start: Run in container: /bin/sh -c /usr/local/julia-devcontainer-features/postcreate.jl
[20730 ms] postCreateCommand failed with exit code 1. Skipping any further user-provided commands.

I'm not able to see anything else.

My devcontainer.json file is just this:

{
    "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
    "features": {
        "ghcr.io/julialang/devcontainer-features/julia:1": {},
    }
}
eitsupi commented 3 months ago

Tell us about your environment (OS, CPU architecture, engine version of Docker etc.)

3f6a commented 3 months ago

I am on macOS (latest version, 14.3), Apple Silicon. I'm not sure how to get the "engine version of Docker"? But should also be the latest. I have Docker Desktop, and update frequently.

3f6a commented 3 months ago

I'm not sure if it's relevant, but since the file that's failing is https://github.com/JuliaLang/devcontainer-features/blob/main/src/julia/postcreate.jl, I am suspicious of the way it determines whether a project is a package or an app, just by looking at whether Manifest exists or not.

eitsupi commented 3 months ago

Thanks. Could you provide a reproducible example according to your speculation that it is related to workspace files?

3f6a commented 3 months ago

I believe I might know what is going on. I have a private registry where my package has some dependencies. Could it be that this feature is trying to install those packages, and failing because it doesn't have access to the registry nor the private repos?

If so, any suggestion on how I might set this up? I'd need to:

  1. Install GitHub CLI on the container, and authenticate with it.
  2. Config Julia to use command line git, which in turn should use gh to authenticate to GitHub.
  3. Add my registry to Julia.

I know how to do these things in my own terminal, or in a container that I configure by hand. But the question is how I could do these things before the Julia feature attempts to instantiate the environment.

Does this sound like a reasonable cause of the issue?

eitsupi commented 3 months ago

I see. I know there have been discussions upstream to make secrets available in such cases, but I don't know if they are actually available now. And, the functionality for adding registries is not currently here, so we will need to add it.

Since I don't know if the secret is available, I think the possible solution now is to add a option to disable the script. PRs are welcome!

3f6a commented 3 months ago

Yes, disabling the postCreate.jl in this tool could be a solution, or allowing us to add our own script. However at that point I'm not sure the feature is that useful, since its setup becomes almost as complicated as just having my own scripts to setup Julia and so on.

But maybe a note in the readme warning users about this limitation (regarding private repos, LocalRegistries, ...) could be helpful.

ahjulstad commented 2 months ago

I have a similar/the same? problem. This github repo contains a minimum non-working example that reproduces the error.

https://github.com/ahjulstad/julia-devcontainer-feature-errror-minimimworkingexample/commit/df768106758afa1752d1994ed69884f7cb49008e

The failure is somehow influenced by the line setting the PATH environment variable here, after commenting out this section everything works OK.

eitsupi commented 2 months ago

@ahjulstad I don't think your problem is relevant. Since you don't seem to need Julia to be installed with this Feature, could you simply not install this Feature?

ahjulstad commented 2 months ago

It is the Julia postCreateCommand that fails, forgot to mention. The error message is similar to the original post.

(But yes, you are probably right that it has nothing to do with private registry) .

eitsupi commented 2 months ago

@ahjulstad IIUC, you are not going to use julia installed by this Feature. So I don't think you should install this Feature.

    ,"remoteEnv": {
        "PATH": "${containerEnv:PATH}:/home/vscode/.julia/conda/3/x86_64/bin"
    }

https://github.com/ahjulstad/julia-devcontainer-feature-errror-minimimworkingexample/blob/df768106758afa1752d1994ed69884f7cb49008e/.devcontainer/devcontainer.json#L24-L26

ahjulstad commented 2 months ago

I am using Julia from this feature. Error still happens if changing the above to:

    ,"remoteEnv": {
        "PATH": "${containerEnv:PATH}"
    }

which I don't really understand why would do anything. After startup I can run Julia or the postcreate.jl script just fine, but the language server does not start.

The resulting path if I delete the remoteEnv statement becomes: /vscode/vscode-server/bin/linux-x64/e170252f762678dec6ca2cc69aba1570769a5d39/bin/remote-cli:/home/vscode/.juliaup/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin

If I keep the remoteEnv statement /home/vscode/.juliaup/bin:/vscode/vscode-server/bin/linux-x64/e170252f762678dec6ca2cc69aba1570769a5d39/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin

Same elements, but slightly different sequence.

(The purpose of the original path setting was to make the Julia-installed python available at the command prompt, with the goal of sharing python environments across devcontainers. And if you ask, why use devcontainers at all; I am on Windows.)

eitsupi commented 2 months ago

@ahjulstad Anyway, I think your problem is a hijacking of the issue and I suggest you open another issue.

eitsupi commented 3 weeks ago

I recently created a feature that has the ability to set a lifecycle script to any lifecycle to test it out and confirmed that it works well. Perhaps the same thing can be done here. rocker-org/devcontainer-features#226