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

cli: set I/O stream to Stdio:null if the given solana_version is already installed #2757

Merged
merged 7 commits into from Jan 6, 2024

Conversation

simplysabir
Copy link
Contributor

Description :

Copy link

vercel bot commented Jan 2, 2024

@simplysabir is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

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

Thank you for your interest in contributing to Anchor!

This implementation doesn't currently solve the issue described in #2724 because the installation progress is still not visible.

cli/src/lib.rs Outdated Show resolved Hide resolved
cli/src/lib.rs Outdated Show resolved Hide resolved
@simplysabir
Copy link
Contributor Author

Thank you for your interest in contributing to Anchor!

This implementation doesn't currently solve the issue described in #2724 because the installation progress is still not visible.

So i Should do this right?

  • If the Solana version is already installed (is_solana_version_installed returns true), it will set the standard I/O streams to null during the installation process.
  • If the Solana version is not installed, it will execute the installation command without redirecting the standard I/O streams, allowing to see the installation progress.

am i right on this approach?

@acheroncrypto
Copy link
Collaborator

am i right on this approach?

Yes, the I/O behavior should change based on whether the version is already installed.

@simplysabir
Copy link
Contributor Author

am i right on this approach?

Yes, the I/O behavior should change based on whether the version is already installed.

Added another implementation kindly have a look.

cli/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

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

These comments don't add any context to what's being done, please remove them.

cli/src/lib.rs Outdated Show resolved Hide resolved
cli/src/lib.rs Outdated Show resolved Hide resolved
cli/src/lib.rs Outdated Show resolved Hide resolved
cli/src/lib.rs Outdated Show resolved Hide resolved
@simplysabir
Copy link
Contributor Author

@acheroncrypto Removed comments and updated the is_solana_version_installed function to be

fn is_solana_version_installed(version: &str) -> Result<bool> {
    let output = std::process::Command::new("ls")
        .arg("-l")
        .arg("~/.local/share/solana/install/releases")
        .output()?;

    if output.status.success() {
        let output_versions = std::str::from_utf8(&output.stdout)?;
        Ok(output_versions.lines().any(|line| line.contains(version)))
    } else {
        Err(anyhow!("Failed to list Solana installed versions"))
    }
}

cli/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

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

Looks great but I've changed ls command to solana-install list to make it simpler and OS agnostic.

Thank you for contributing!

@acheroncrypto acheroncrypto merged commit 7cbdff6 into coral-xyz:master Jan 6, 2024
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants