box install does not save to box.json

after running “box upgrade” I see:

$ box version
CommandBox 1.0.0.00075

I have an existing box.json, created with “box init”.

I run:

$ box install mockbox --saveDev

I get

ERROR

The directory [/path/to/project/–saveDev] doesn’t exist.

If I run

$ box install mockbox
Contacting ForgeBox, please wait…
Found entry: ‘mockbox’
Installing from local artifact cache…
Eureka, ‘mockbox’ has been installed!

It works fine and mockbox is installed.

So how do I get it to save it as a dev dependency? I tried --save as well and that also gave an error.

I also tried building from the latest source and running that, that showed the same version as above and gave the same error.

Any ideas?

Mac OS X 10.9.4

OK, more on this…

I just ran “box install mockbox” again and it overwrote my projects box.json file with MockBox’s box.json! Since there were no --save or --saveDev flags it should have left my box.json alone!

Thats not good. :slight_smile:

What was the output from upgrade? You might need to use the force=true option as I’m not sure it takes the build number into account right now.

Also, if you build from source, you’ll probably need to delete your .CommandBox folder from your user directory so the binary will re-extract the next time it is run.

We’re still ironing out our upgrade process, and we’re not really bumping our version numbers yet since we haven’t done our official first beta release.

Also, a side question: are you actually running “box command” from your native OS shell, or running “box” to enter the CommandBox shell, and then running “command” from their?
I’m mostly just curious. They both do the same, though if you’re going to run several commands, it’s faster to load the shell once and stay inside it.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

See below. Thanks Brad.

What was the output from upgrade? You might need to use the force=true option as I’m not sure it takes the build number into account right now.

$ box upgrade
Resolved dependency com.ortussolutions:box.cli:1.0.0:cfml:zip…
Unzipping /Users/sean/.CommandBox/artifacts/com/ortussolutions/box.cli/1.0.0/box.cli-1.0.0-cfml.zip…

Reloading shell…
Installed 1.0.0

Also, if you build from source, you’ll probably need to delete your .CommandBox folder from your user directory so the binary will re-extract the next time it is run.

$ rm -rf ~/.CommandBox/

$ box upgrade
Configuring CommandBox home: /Users/sean/.CommandBox (change with -CommandBox_home=/path/to/dir)
Library path: /Users/sean/.CommandBox/lib
Initializing libraries – this will only happen once, and takes a few seconds…

Libraries initialized
Downloading http://cfmlprojects.org/artifacts/com/ortussolutions/box.cli/maven-metadata.xml
Downloading http://cfmlprojects.org/artifacts/com/ortussolutions/box.cli/1.0.0/box.cli-1.0.0-cfml.zip
Resolved dependency com.ortussolutions:box.cli:1.0.0:cfml:zip…
Unzipping /Users/sean/.CommandBox/artifacts/com/ortussolutions/box.cli/1.0.0/box.cli-1.0.0-cfml.zip…

Reloading shell…
Installed 1.0.0

We’re still ironing out our upgrade process, and we’re not really bumping our version numbers yet since we haven’t done our official first beta release.

Also, a side question: are you actually running “box command” from your native OS shell, or running “box” to enter the CommandBox shell, and then running “command” from their?
I’m mostly just curious. They both do the same, though if you’re going to run several commands, it’s faster to load the shell once and stay inside it.

I have tried it both ways. Same error in both cases. I was primarily using my OS shell (bash 4), however.

install mockbox --saveDev

ERROR

The directory [/Users/sean/Sites/ari/fdr.aesnet.org/–saveDev] doesn’t exist.

I just tried this and it worked correctly. Can you ensure you’ve wiped out the old version of CommandBox and installed the latest?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

$ rm -rf ~/.CommandBox/
$ box upgrade

Running “upgrade” there isn’t necessary since you just removed Command Box so the first thing it’s going to do is install. Where is the “box” binary resolving to and can you confirm it’s a version you just downloaded/built?

Also, the output of your upgrade command shows it didn’t actually download-- it just used a local copy. Looking at the code, it appears the force flag doesn’t work fully if you have the file in your local artifacts dir. In fact, that’s quite possibly messing you up if you’re running the upgrade command after you install. You may be overwriting the installation with an old version.

Try removing the directory, rerunning the box binary but don’t do upgrade.

> I have tried it both ways. Same error in both cases.

Well yes, that is expected since it’s the same code so both would work or both would not. I just wanted to see how most people were using CommandBox.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

OK… that worked.

$ rm -rf ~/.CommandBox

$ curl -o ~/Downloads/commandbox.zip http://integration.staging.ortussolutions.com/artifacts/ortussolutions/commandbox/1.0.0/commandbox-1.0.0.bin.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 33.1M 100 33.1M 0 0 887k 0 0:00:38 0:00:38 --:–:-- 1182k

$ unzip ~/Downloads/commandbox.zip -d ~/Downloads/commandbox
Archive: /Users/sean/Downloads/commandbox.zip
inflating: /Users/sean/Downloads/commandbox/box

$ which box
/usr/local/bin/box

$ cp ~/Downloads/commandbox/box /usr/local/bin/box

$ box version
Configuring CommandBox home: /Users/sean/.CommandBox (change with -CommandBox_home=/path/to/dir)
Library path: /Users/sean/.CommandBox/lib
Initializing libraries – this will only happen once, and takes a few seconds…

Libraries initialized
CommandBox 1.0.0.00079

sean at Seans-iMac in ~/Sites/ari/fdr.aesnet.org on summer2014changes-coires [+!?]
$ box install mockbox --saveDev

Installing package: mockbox
Verifying package ‘mockbox’ in ForgeBox, please wait…
Verified entry in ForgeBox: ‘mockbox’
Package found in local artifacts!
Installing to: /Users/sean/Sites/ari/fdr.aesnet.org//mockbox
-> 80 File(s) Installed
-> 0 File(s) ignored
box.json updated with dev dependency.
Eureka, ‘mockbox’ has been installed!

It updated my box.json. It also added some keys that I had removed, namely the “testbox” key. I am not using testbox (old project still on CF9 so I gotta use mxunit) So I had removed that. Is that expected behavior? To add config settings that I had removed? Its fine if it is, just wanted to bring it to your attention.

Thanks for your help.

Sean

> It updated my box.json.

I’m glad you got it working.

> It also added some keys that I had removed, namely the “testbox” key. Is that expected behavior?

Yes, it is expected. Here’s what happens: when a command wants to read values from box.json it runs PackageService.readPackageDescriptor( directory ). This reads the box.json, parses the JSON, and APPENDS it into the template box.json file to ensure that all default values are there as expected. I did this to prevent having a large amount of structKeyExists() checks littered in the code. So, when the install command reads the box JSON, it gets a version with all the bits defaulted which it then write back out.

Now, that being said-- it doesn’t HAVE to work that way-- it’s just was simple and made sense at the time. I could add a flag to readPackageDescriptor() to not default values and then use that if I plan on writing the box.json back out. Feel free to put in a ticket for that enhancement: https://ortussolutions.atlassian.net/browse/COMMANDBOX

Also, on a related note, you can look at and modify box.json values using the package show, package set, and package clear commands. Check out their help as they allow access to nested data structure, setting complex data via JSON and appending to arrays and structs. Of course, editing the file by hand might be quicker, but this gives you a way to automate the process. The commands even have nice tab-completion that shows you all the possible properties currently in your box.json to work with.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Just an update on the last E-mail in this thread. Last night I put in COMMANDBOX-135 and completed it. It prevents CommandBox from writing out default properties in your box.json that you have removed. So, if you remove the “testbox” struct and then install or uninstall something, ONLY the relevant parts of your box.json will be touched. Also “package show” will only show what’s actually in there, and “package set” will not add things in either.

You can try this out with

upgrade --latest

Let me know if you find any other places where we’re adding default props back in.

Thanks!

~Brad