Skip to content

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

Merged
acheroncrypto merged 7 commits into
otter-sec:masterfrom
simplysabir:master
Jan 6, 2024
Merged

cli: set I/O stream to Stdio:null if the given solana_version is already installed#2757
acheroncrypto merged 7 commits into
otter-sec:masterfrom
simplysabir:master

Conversation

@simplysabir

Copy link
Copy Markdown
Contributor

Description :

@vercel

vercel Bot commented Jan 2, 2024

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated
@simplysabir

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread cli/src/lib.rs Outdated

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated
@simplysabir

Copy link
Copy Markdown
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"))
    }
}

Comment thread cli/src/lib.rs Outdated

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

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 otter-sec:master Jan 6, 2024
Otter-0x4ka5h pushed a commit to Otter-0x4ka5h/anchor that referenced this pull request Mar 25, 2026
…already installed (otter-sec#2757)

Co-authored-by: acheron <acheroncrypto@gmail.com>
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.

3 participants