Skip to content

[script] install nodes in ~/.local/share/otns so that OTNS can run from anywhere#773

Open
EskoDijk wants to merge 1 commit into
openthread:mainfrom
EskoDijk:pr-install-node-binaries
Open

[script] install nodes in ~/.local/share/otns so that OTNS can run from anywhere#773
EskoDijk wants to merge 1 commit into
openthread:mainfrom
EskoDijk:pr-install-node-binaries

Conversation

@EskoDijk
Copy link
Copy Markdown
Contributor

The installation is updated to copy node executables to a .local/share directory. This directory is added to the node search path, so that standard OT node executables can be found from any directory location where OTNS is run from. The build and copying of node executables is added to the './script/install' script.

Close #587

…om anywhere

The installation is updated to copy node executables to a .local/share directory. This directory
is added to the node search path, so that standard OT node executables can be found from any
directory location where OTNS is run from. The build and copying of node executables is added to
the './script/install' script.

Close openthread#587
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the portability and ease of use for OTNS by standardizing the installation location for OpenThread node executables. By moving these binaries to a user-specific shared directory and updating the search paths, users can now run OTNS from any directory without encountering issues related to missing node executables. This change streamlines the setup process and improves the overall developer experience.

Highlights

  • Node Executable Installation Path: OpenThread node executables are now installed in ~/.local/share/otns/bin, allowing OTNS to locate them regardless of the current working directory.
  • Installation Script Refactoring: The main script/install has been refactored into two specialized scripts: script/install-otns (for OTNS and pyOTNS) and script/install-nodes (for building and installing node executables).
  • Search Path Update: The OTNS simulation configuration now includes ~/.local/share/otns/bin in its executable search paths.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • GUIDE.md
    • Updated the installation command for OTNS from ./script/install to ./script/install-otns.
  • ot-rfsim/ot-versions/README.md
    • Added a note clarifying that built executables are copied to ~/.local/share/otns/bin by script/install-nodes.
  • script/install
    • Updated copyright year to 2026.
    • Refactored main function to call install_otns and install_nodes instead of directly implementing their logic.
    • Removed install_pyotns function, as its logic was moved to script/install-otns.
  • script/install-nodes
    • Updated copyright year to 2026.
    • Added a new function install_nodes_to_local_share to create ~/.local/share/otns/bin and copy node executables into it.
    • Integrated install_nodes_to_local_share into the main function.
  • script/install-otns
    • Added a new script to handle the installation of OTNS and pyOTNS, including go mod tidy, go_install, and python3 -m pip install ..
  • script/test
    • Updated copyright year to 2026.
    • Modified install_otns function to call ./script/install-otns instead of ./script/install.
  • simulation/node_config.go
    • Updated DefaultExecutableConfig.SearchPaths to include filePathInUserHomeDir(".local/share/otns/bin").
    • Corrected a typo from "relay" to "rely" in a comment.
  • simulation/utils.go
    • Updated copyright year to 2026.
    • Added a new function filePathInUserHomeDir to construct a file path relative to the user's home directory.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/build.yml
    • .github/workflows/develop.yml
    • .github/workflows/lint.yml
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the installation scripts to separate the installation of OTNS from the OT nodes. It also updates the installation process to copy node executables to a user-local directory (~/.local/share/otns), allowing OTNS to be run from any location. This is a valuable improvement for user experience. My review includes a couple of suggestions to enhance the robustness and standards-compliance of the implementation in both the shell script and Go code.

Comment thread script/install-nodes
Comment on lines +36 to +37
mkdir -p ~/.local/share/otns/bin
cp ./ot-rfsim/ot-versions/* ~/.local/share/otns/bin/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For better compliance with the XDG Base Directory Specification and to improve robustness, consider using the $XDG_DATA_HOME environment variable, which defaults to $HOME/.local/share. This avoids hardcoding the path and respects user configurations. Using a variable also makes the code cleaner by avoiding repetition.

Suggested change
mkdir -p ~/.local/share/otns/bin
cp ./ot-rfsim/ot-versions/* ~/.local/share/otns/bin/
otns_data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/otns/bin"
mkdir -p "$otns_data_dir" && cp ./ot-rfsim/ot-versions/* "$otns_data_dir/"

Comment thread simulation/utils.go
Comment on lines +40 to +46
func filePathInUserHomeDir(relPath string) string {
home, err := os.UserHomeDir()
if err == nil {
return filepath.Join(home, relPath)
}
return "/tmp/UserHomeDirNotFound"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error handling for os.UserHomeDir() can be made clearer. Returning a magic string like /tmp/UserHomeDirNotFound without context can be confusing for future maintenance. It's good practice to add a comment explaining why a fallback path is returned. Also, using a guard clause for the error check would improve readability.

func filePathInUserHomeDir(relPath string) string {
	home, err := os.UserHomeDir()
	if err != nil {
		// os.UserHomeDir() can fail in some environments (e.g. when cross-compiling).
		// Return a path that is unlikely to exist, so the executable search will
		// gracefully fail for this path and continue with other search paths.
		return "/tmp/otns-home-dir-not-found"
	}
	return filepath.Join(home, relPath)
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OT node executables not found when running otns from a different (non-default) directory

1 participant