Resolving Resource Files Shipped with a Program
A bundled resource belongs to the installed package or configured resource location. The caller's working directory may be unrelated.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a different launch location
A command works from its repository because a relative template file exists there. Starting the same command from another directory makes the template lookup fail. See working directory rules.
Test the installed layout
Run the packaged command from a temporary caller directory and verify the template is found through the intended resource interface. Validating an artifact captures the correct boundary.[1]
Load a packaged resource independently of startup location
A command installed into a different environment starts from the user's current directory. A default template shipped with the program belongs to the package's resource layout. Resolving it from the startup directory can accidentally select a local file or fail. See the shell working directory.
Program started in /work
Packaged template lives under the installed package resources
Read through the supported package resource mechanism
Use explicit configuration for user-owned paths
A user input path may intentionally be relative to the current directory. Keep that policy distinct from locating package data. Test the installed artifact from an unrelated directory and check both resource types.