Hi all,
I’m running into some behavior with CommandBox that I don’t quite understand and I’m hoping that someone can help to clarify. Depending on how I start CommandBox, it seems like sometimes it can follow relative paths to dependencies and mappings and sometimes it can’t.
Background:
I have an application with the following structure (p.s. It’s a LONG story why we’re using a zip file):
Project-Folder
|- install/
|- myModule.zip
|- box.json
The box.json file declares an application dependency for myModule and points to the myModule.zip file in the install directory:
# box.json contents
...
"dependencies": {
"myModule":"file:install/myModules.zip"
}
...
The problem
Depending on how I run the install
command in CommandBox CLI, I get different results.
Method 1 (Successful)
I do most of my work in VSCode using the integrated terminal. Generally I use gitBash as my terminal shell, but when I need to do some CommandBox awesomeness I generally switch into commandbox using the “box” command:
- Happily coding away in my project folder in VSCode
- Open a terminal (defaults to the project root folder)
- Type
box
to enter the CommandBox CLI (box.exe is in the windows path) - Read the CommandBox message of the day
- Type
install
in CommandBox CLI
Result: CommandBox successfully installs the module from the Project-Folder/install/myModule.zip
location. And there is much rejoicing!
Method 2 (CommandBox can’t find file):
Unfortunately if I start off by loading the CommandBox CLI by double-clicking on box.exe
and then try and run the install script, CommandBox throws an error that indicates that it can’t find the file based on the relative mapping:
- Launch
box.exe
via Windows explorer (as adminsitrator) to open CommandBox CLI interface -
cd
toProject-Folder
(validating location usingpwd
) - Type
reload
to force CommandBox to reload the shell (just in case it matters) - Type
install
in CommandBox CLI
Result:
× | Installing ALL dependencies
|------------------------------------------
| × | Installing package [file:install/myModule.zip]
| | > file or directory [install/myModule.zip] does not exist
| |--------------------------------------------------------------------
ERROR (5.0.1+00137)
file or directory [install/myModule.zip] does not exist
Can someone help me understand why CommandBox might be having a hard time following the dependencies (and mappings) in the second scenario above? Is there something that I’m missing or forgetting to do? I was assuming that a reload
would reset the context that CommandBox is running in and the relative paths would work (the way it does in the VSCode/Integrated terminal example) but my mental model here is far from complete.
Environment Details
- OS: Windows 10
- CommandBox Version (verified behavior in 5.0.1 and 5.1.1)
Thanks!