Skip to content

java feature fails to install #1582

Description

@jakub-bochenski
4.731 Check if OpenJDK is available for version 17 for ms Distro
4.733 sh: 34: /usr/local/sdkman/bin/sdkman-init.sh: source: not found
4.734 sh: 65: /usr/local/sdkman/bin/sdkman-init.sh: [[: not found
4.734 sh: 67: /usr/local/sdkman/bin/sdkman-init.sh: [[: not found
4.734 sh: 79: /usr/local/sdkman/bin/sdkman-init.sh: Syntax error: "(" unexpected

https://github.com/devcontainers/features/blob/main/src/java/install.sh#L221

https://github.com/devcontainers/features/blob/main/src/java/install.sh#L235

You can't just source bash files from arbitrary shell

Activity

  1. jakub-bochenski commented on Feb 18, 2026

    @jakub-bochenski
    Author

    A workaround is to set the default shell when creating you user:

    useradd --system --create-home --uid 500 --gid 500 --shell /bin/bash ${USERNAME}
    

    But a real fix would be to select bash as shell for su -c if you need the shell to be bash

  2. v-Kaniska244 commented on Mar 9, 2026

    @v-Kaniska244
    Contributor

    Hi jakub-bochenski

    Thank you for reporting this issue. As its mentioned here, bash shell is actually required for the platform to install the java dev container feature.

  3. jakub-bochenski commented on Mar 9, 2026

    @jakub-bochenski
    Author

    Thanks for the clarification. I understand that bash is required by the feature scripts.

    However, the issue here isn’t that bash is unavailable — it’s that the script invokes su -c without specifying the shell. In that case, the command is executed using the target user's login shell. If that shell is /bin/sh, the script ends up sourcing sdkman-init.sh with sh, which fails because it contains bash-specific syntax (source, [[ ]], etc.).

    So even when bash is installed, the install step can still fail depending on the user's configured shell.

    One workaround is to create the user with /bin/bash as the login shell:

    useradd --system --create-home --uid 500 --gid 500 --shell /bin/bash ${USERNAME}
    

    But a more robust fix would be to explicitly run the command with bash when using su -c, for example:

    su - ${USERNAME} -s /bin/bash -c "<command>"
    

    or

    su - ${USERNAME} -c "bash -lc '<command>'"
    

    That would ensure the feature works regardless of the user's default shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions