GithubHelp home page GithubHelp logo

Comments (3)

chriskrycho avatar chriskrycho commented on June 15, 2024

Thanks for the report! Is this package-manager-specific behavior or do we get it wrong for regular packages as well?

from volta.

jasonmobley avatar jasonmobley commented on June 15, 2024

Thanks for the report! Is this package-manager-specific behavior or do we get it wrong for regular packages as well?

I think it is specific to the special packages that volta considers "tools" like npm, pnpm, yarn, etc. But there's also a volta bug in the general package case, because it thinks it should be trying to identify a newly installed package when there isn't one.

→ volta ls gulp
⚡️ No tools or packages installed.

You can safely install packages by running `volta install <package name>`.
See `volta help install` for details and more options.

→ npm ls -g gulp
/Users/me/.volta/tools/image/node/16.20.2/lib
└── (empty)


→ npm install -g --dry-run gulp

added 336 packages in 8s

16 packages are looking for funding
  run `npm fund` for details
Volta error: Could not determine the name of the package that was just installed.

Please rerun the command that triggered this error with the environment
variable `VOLTA_LOGLEVEL` set to `debug` and open an issue at
https://github.com/volta-cli/volta/issues with the details!

from volta.

chriskrycho avatar chriskrycho commented on June 15, 2024

Ah, very interesting. Thanks for flagging up that second issue as well! If you have time and interest to dig in, the relevant code is here:

use std::path::PathBuf;
use super::manager::PackageManager;
use crate::command::create_command;
use crate::error::{Context, ErrorKind, Fallible};
use crate::platform::Image;
use crate::style::progress_spinner;
use log::debug;
/// Use `npm install --global` to install the package
///
/// Sets the environment variable `npm_config_prefix` to redirect the install to the Volta
/// data directory, taking advantage of the standard global install behavior with a custom
/// location
pub(super) fn run_global_install(
package: String,
staging_dir: PathBuf,
platform_image: &Image,
) -> Fallible<()> {
let mut command = create_command("npm");
command.args(&[
"install",
"--global",
"--loglevel=warn",
"--no-update-notifier",
"--no-audit",
]);
command.arg(&package);
command.env("PATH", platform_image.path()?);
PackageManager::Npm.setup_global_command(&mut command, staging_dir);
debug!("Installing {} with command: {:?}", package, command);
let spinner = progress_spinner(format!("Installing {}", package));
let output_result = command
.output()
.with_context(|| ErrorKind::PackageInstallFailed {
package: package.clone(),
});
spinner.finish_and_clear();
let output = output_result?;
let stderr = String::from_utf8_lossy(&output.stderr);
debug!("[install stderr]\n{}", stderr);
debug!(
"[install stdout]\n{}",
String::from_utf8_lossy(&output.stdout)
);
if output.status.success() {
Ok(())
} else if stderr.contains("code E404") {
// npm outputs "code E404" as part of the error output when a package couldn't be found
// Detect that and show a nicer error message (since we likely know the problem in that case)
Err(ErrorKind::PackageNotFound { package }.into())
} else {
Err(ErrorKind::PackageInstallFailed { package }.into())
}
}

(No worries if not!)

from volta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.