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

pkg export and hab-sup/hab-launcher commands should honor fs_root #5592

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

mwrock
Copy link
Contributor

@mwrock mwrock commented Sep 8, 2018

This week @trevorghess noticed that hab pkg export docker inside of a local windows studio was failing with:

thread 'main' panicked at 'Could not find 'docker' in the 'core/docker' package!

After researching this it ends up that hab pkg export commands do not honor the FS_ROOT environment variable on Windows which will cause export to break in a local (non-docker) studio.

This fixes that scenario. It also fixes another case I have been aware of for a while but was not broken enough to research. Formerly hab-launch and hab-sup binary calls have not honored fs_root either. This means that in a local Windows studio, the launcher and supervisor binaries in c:\hab\pkgs are invoked. Functionally that is really not a big deal but is out of alignment with the self contained nature of a studio.

Signed-off-by: mwrock matt@mattwrock.com

@thesentinels
Copy link
Contributor

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

Copy link
Contributor

@baumanj baumanj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion to make the code more understandable, which you can use or not.

@@ -77,8 +77,8 @@ where
return Err(Error::ExecCommandNotFound(command));
}

let fs_root_path = Path::new("/");
match PackageInstall::load_at_least(ident, None) {
let fs_root_path = Path::new(&*FS_ROOT_PATH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

    let fs_root_path = FS_ROOT_PATH.as_path();

I think doing this more explicitly is easier to understand for those who may not intuitively understand all of the rust magic going on here. Especially when the name FS_ROOT_PATH doesn't make it clear that its type is actually a reference to a PathBuf.

    let fs_root_path = &*FS_ROOT_PATH;

Works too, but I think that while it's shorter, it's more confusing.

@@ -605,8 +606,9 @@ fn supervisor_cmd() -> Result<PathBuf> {
return Ok(PathBuf::from(command));
}
let ident = PackageIdent::from_str(SUP_PACKAGE_IDENT).unwrap();
match PackageInstall::load_at_least(&ident, None) {
Ok(install) => match core::fs::find_command_in_pkg(SUP_CMD, &install, "/") {
let fs_root_path = Path::new(&*FS_ROOT_PATH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

Signed-off-by: mwrock <matt@mattwrock.com>
@mwrock mwrock merged commit f1d7471 into master Sep 11, 2018
@mwrock mwrock deleted the fs_local branch September 11, 2018 15:20
chef-ci pushed a commit that referenced this pull request Sep 11, 2018
Obvious fix; these changes are the result of automation not creative thinking.
@christophermaier christophermaier added Focus:Launcher Related to the Habitat Launcher (core/hab-launcher) component Focus: Studio Related to the Habitat Studio (core/hab-studio) component Focus: CLI Related to the Habitat CLI (core/hab) component Platform: Windows Deals with Windows-specific behavior and removed A-launcher labels Jul 24, 2020
@christophermaier christophermaier added Type: Bug Issues that describe broken functionality and removed C-bug labels Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus: CLI Related to the Habitat CLI (core/hab) component Focus:Exporter Focus:Launcher Related to the Habitat Launcher (core/hab-launcher) component Focus: Studio Related to the Habitat Studio (core/hab-studio) component Platform: Windows Deals with Windows-specific behavior Type: Bug Issues that describe broken functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants