Author Topic: Portability  (Read 13845 times)

guigz

  • Guest
Portability
« on: May 03, 2006, 04:42:25 am »
Is there a way to ask codeblock to write all his config settings in a file in win32 and not in the registry?

I'd like to have a portable IDE to put it on an USB key to develop with the same environment on any PC I'll be on...

Thanks

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Portability
« Reply #1 on: May 03, 2006, 05:31:52 am »
The good thing is Code::Blocks is not using the registry anymore (this change was made a long time ago), even though I have my doubts the place for this file can be changed without modifying the source code. This could then sound like a feature request, and should be easy to implement.

The file is named default.conf. If you want to know where it's saved try searching in the forums (it has been said many times for the different platforms).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #2 on: May 03, 2006, 09:08:46 am »
Is there a way to ask codeblock to write all his config settings in a file in win32 and not in the registry?
You're obviously using the RC2 version (or else you would not be asking). Sorry, but the answer is no. Although RC2 has a plugin to export settings, it never worked.
In fact, it is even worse than that. You will lose your settings when switching to a newer version. However, the good news is that it is worth it.

The current version of Code::Blocks saves its settings to an XML file which has the same name as your current profile (by default, that is "default", but you can launch Code::Blocks with --profile=anyname).

The file is always saved in the "correct" place depending on the operating system. For Linux/Unix, that is ~/.codeblocks, and for Windows, that is the location of the application data shell variable (in a "normal" setting, if there is such thing, something like C:\Documents and Settings\YourName\Application Data. Some older Windows version bury app data somewhere deep inside the Windows folder, and the user can also configure it to be in an arbitrary place).

Contrarily, the application loads its settings from a diversity of places. If it can find settings in the application data folder, it will use these, but if there are none, it will for example also search in the folder where the application is installed.
This was done so you can copy the application as well as your preferred settings onto a removable (possibly read-only) disk together with custom settings that you wish to use.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

guigz

  • Guest
Re: Portability
« Reply #3 on: May 03, 2006, 09:46:19 am »
I use the RC2..

Code::Blocks creates entries in my registry (HKEY_CURRENT_USER\Software)/
It also create a directory in my userprofile dir.

What I want is something more simple:1 config file in the same directory of the Code::Block exe.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Portability
« Reply #4 on: May 03, 2006, 09:50:53 am »
What I want is something more simple:1 config file in the same directory of the Code::Block exe.
This is already implemented in current SVN head. C::B supports (a) config file(s) in the user profile (application data) folder and a config file in the path of C::B. I suggest you update to one of the nightlies and you're done. ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Portability
« Reply #5 on: May 03, 2006, 10:06:27 am »
I use the RC2..

Code::Blocks creates entries in my registry (HKEY_CURRENT_USER\Software)/
It also create a directory in my userprofile dir.

What I want is something more simple:1 config file in the same directory of the Code::Block exe.


what you want is not robust and user friendly, let me explain :
1) config files should (this config file is also some sort of profile : eg : I have added some more compilers) not be put real close to the program. Say you want to upgrade and you first uninstall, say it's a bad (un)installer (there exist plenty of those!!!) and it removes everything in the folder of the application --> bye bye your prescious config file
2) say you have your M$ profiles on another harddisk then windows (advice advice advice, just do that), when winBLOWS it can't take down your profile, and you can copy from it after fresh windows install (after the blow, probably your apps are gone to ;-) )
3) multi-users, say there are different users on your machine, maybe I don't like your settings, and I want things to look a bit different, or maybe you don't like the compilers I added. Every user should have his/her own settings. So where do you put such stuff then : in the home directory (linux) or M$ profile (windows)
guess where the default.conf is now ;-)

as Thomas explained you can do what you want, use the startup parameter, and create an shortcut that always starts up with your profile as the extra param towards CB

But I guess the majority of users will prefer things that provide/solve the above 3 issues

kind regards,
Lieven
« Last Edit: May 03, 2006, 10:20:39 am by killerbot »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #6 on: May 03, 2006, 10:32:57 am »
Maybe I did not explain myself thoroughly enough.

You can copy your config file to the executable's folder. It is just not the default location.

Code::Blocks will always use a configuration file that it finds in your user profile directory. However, it will also accept a configuration file that is inside the executable folder, if none is found elsewhere.

Quote
Code::Blocks creates entries in my registry (HKEY_CURRENT_USER\Software)/
It also create a directory in my userprofile dir.
Then you have two versions of Code::Blocks on your machine (or the registry settings are old).
Code::Blocks only does one or the other, not both (RC2 = registry, newer versions = config file).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

guigz

  • Guest
Re: Portability
« Reply #7 on: May 03, 2006, 10:47:35 am »
I do know that this kind of things is not very good for multiuser system,but suppose I take code::block on an usb key and use it on my friend's computers.I'll leave garbages in his registry and user account, and this guy won't be my friend anymore....
With a MonoUser version,I can have My Code::Blocks with my settings on my USB key which can work on his own,without leaving any Garbages on any computer....It's better than MultiUsers since I don't even need a user account....It's easier for me to go on other machines since I do not have to install a whole new CodeBlock and compilers and libraries to be able to work.You'll tell me that it's a waste of space in a multiuser environment, yes it is. But: Code blocks with MingW is 90Mo without wxwidget. An external HardDrive of 40Go is 90euros.You can get a 1Gb USB key for less....I don't care about a multiuser environment. They are good only at work. I just have one account on my laptop.When I go at my friend, he won't create an account for me, he'll just log on his account.It's better for me to have my portable CodeBlocks than a big multiuser-care one which I do not use.If you don't believe it's interesting,just check portableapps.com or www.portablefreeware.com.

Why not add this feature?
Just add a command line  command to tell codeblock to write all his settings in a subdirectory called \settings(for example).That way,to upgrade code blocks,you just have to replace binaries and keep the settings as is...


I use the RC2 version of codeblocks(I downloaded it yesterday)
The directory in my userprofile is an empty one.So it's garbage.
Where can I get newer versions?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Portability
« Reply #8 on: May 03, 2006, 11:17:18 am »
allrighty here we go :

1) RC2 --> uninstall, it is old
2) manually install MingW (or maybe you had it already installed somewhere, then just keep it)
3) download the latest nightly, they are advertised daily in the nightly builds forum (http://forums.codeblocks.org/index.php?board=20.0)
4) reread Thomas's reply, with these newer version you can specify which configuration file to use (--profile=anyname).
Come to think of it, should check ; anyname is profile name or just the conf file name (@Thomas : do you know this by heart ?)

If 4) is a "profile" name then it won't work from the stick since it will look for that profile on your friends computer .... if that profile does not exist -> won't find it, it will fall back to the conf file next to the exe (where you have put your PC's default.conf), so in the end it might work.

Lieven
PS: I also like the "portable" software, so no need to convince me for that ;-)

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Portability
« Reply #9 on: May 03, 2006, 12:02:51 pm »
Quote
Come to think of it, should check ; anyname is profile name or just the conf file name (@Thomas : do you know this by heart ?

It's the profile name, not the filename.

@guigz:
Why are you making such a big deal out of this? Please read carefully what's been written here. There is no problem to use it like you want.
Just create an empty file named default.conf on your USB stick and you 're ready to go.
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #10 on: May 03, 2006, 12:37:06 pm »
4) reread Thomas's reply, with these newer version you can specify which configuration file to use (--profile=anyname).
Come to think of it, should check ; anyname is profile name or just the conf file name (@Thomas : do you know this by heart ?)
As it happens, I do :)
But he does not need to use the --profile switch, he can just copy the default config file to the app's directory too.
That is, if he ever cares to read the above posts...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Portability
« Reply #11 on: May 03, 2006, 01:53:46 pm »
Code::Blocks will always use a configuration file that it finds in your user profile directory. However, it will also accept a configuration file that is inside the executable folder, if none is found elsewhere.

Well, this gives the impression it first looks in the profile dir, and if nothing there, only then next to the exe. That meanss if you connect your stick into a CB-equipped PC, it will take the PC-config and not the stick one. Or am I seeing ghosts ?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #12 on: May 03, 2006, 03:42:04 pm »
Yes, that is exactly what is done. It makes sense, too, think about it.

If there is a config file in the user's profile folder, then obviously, the user will want to use this one.  It is a valid assumption that if you have settings saved in your user profile, then you really want to use these. Nothing else makes sense.

However, if no config file can be found in the user's profile, then Code::Blocks does not know about the user's wishes to start with. This may change after RC3, when we include the divination plugin, but to date, we are utterly clueless about our user's thoughts.

However, if you put the application onto a CDROM or a Flash-Stick, and you pack a config file into the same directory as the application, then it is a reasonable guess that you actually want Code::Blocks to use that configuration rather than factory settings.
Again, we cannot possibly know what is going on inside someone's head, but this is what people would probably want.

Finally, in the case that no configuration can be found in any place (including the executable's directory), Code::Blocks creates the well-known default.conf in the user's profile folder. Obviously, the vast majority of users wants settings to be persistent, and people would be upset if they had to turn off "Tip of the day" every time the application starts ;)

Hint:
I forgot to mention that earlier, sorry: If you really want to be roaming, roaming, roaming, roooooaming, then put your config file onto a webserver and start Code::Blocks with the option
--profile=http://url.to/your.conf. That way, Code::Blocks gets its configuration off the internet, and it starts exactly the same way every time, on every PC.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Guest

  • Guest
Re: Portability
« Reply #13 on: May 03, 2006, 05:07:48 pm »
I'm using the latest nightly on WinXP-SP2. I renamed the codeblocks-folder in my profile and put the conf-file into the app-directory, but it didn't use this file. Instead a new config has been created in my profile. I've also tried using the --profile option with relative and absolute paths without having any success.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #14 on: May 03, 2006, 07:46:15 pm »
Yes my bad, fixed that.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Guest

  • Guest
Re: Portability
« Reply #15 on: May 03, 2006, 08:11:39 pm »
Thank you! Code::Blocks really rocks  :D

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Portability
« Reply #16 on: May 07, 2006, 09:03:04 pm »
Yes, that is exactly what is done. It makes sense, too, think about it.

If there is a config file in the user's profile folder, then obviously, the user will want to use this one.  It is a valid assumption that if you have settings saved in your user profile, then you really want to use these. Nothing else makes sense.

I don't think that is true at all.  What if you have one computer that already has CB on it, but you would like to use a specific self contained version, with a  configuration file in the exectuables directory.  Right now, the slef contained version of CB will use the current user config file, not the one in its current directory.  I think that if there is a config file in the directory with CB that should be used first, then the user configuration file.  After all, CB will never put a configuration file there on its own, so if there is a config file there, the user wants it used.

Of course there could be an environment variable that could tell CB to favor the application directory over the user directory, but that feels kind of hacky.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #17 on: May 07, 2006, 10:34:02 pm »
Well, you can do whatever you want, it does not matter, there will always be some people who are unhappy with it. We cannot fulfill every demand.

The sole reason why Code::Blocks will actually be so nice as to read a configuration file located in the executable folder at all is because someone wanted to distribute a pre-configured system on a CDROM and asked for a way to somehow do that. Personally, I don't see why you would want to do that at all (except if you wanted kind of a "rescue disk"), but alas... it was asked for, and there it is.

However, generally, Code::Blocks stores its configuration in the "correct" place (the user's profile dir), and it certainly uses the configuration from that place.
The normal mode of operation for an IDE (as for many programs) is being installed on a machine, not being run from a removable medium. While we do support the latter case (more than most other software, if I may dare say this), it is not the default behaviour.
Also, using the executable's directory as a fallback is a free operation in the normal case, while using it as a primary location adds constant overhead.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Portability
« Reply #18 on: May 10, 2006, 12:32:52 am »
You are correct that you can't make everyone happy, but I will stand by my statement that if a config file is found in executable directory it makes sense to use that one over the home directory config file.  That is all mute though because I just realized a simple shortcut that supplies the "--profile" switch will solve all the issues.  You just have to include that shortcut with your self contained copy of CB, and problem solved.

guigz

  • Guest
Re: Portability
« Reply #19 on: May 11, 2006, 08:47:01 am »
"The normal mode of operation for an IDE (as for many programs) is being installed on a machine, not being run from a removable medium"
I disagree.
Supposing I'm using CodeBlocks at work,it's kinda cool to be able to carry all my workspace/feature/IDE with me to bring it home without taking with me the whole PC,and without having to install it on each pc I'll be working on.Moreover,I just changed my pc and deployment of my portable apps was a lot easier than the nonportable ones since I didn't have to install them.Just copy them.Finally,supposing you have a kinda roaming work(well,you don't know which pc you'll be on),having it on a usb key is cool since you just have to plug your usb key on your client's pc and you're at home,even in guest session...One of my friend is using eclipse(for java developpement) and he's very happy with the fact that it's portable since he can put it on his usb key and use it on any pc at work,even the ones not connected to the domain network and this without installing anything nor creating sessions.It's cool for me too since he just gave me a copy of it to parse a java program.I do not have to install the whole thing and guess how it work or is configured to be able to read the java project with syntax highlighting and test and debug it to see how it works...That's definitely a good point since I'm not using java and definitely do not want to install the whole thing on my pc....

guigz

  • Guest
Re: Portability
« Reply #20 on: May 11, 2006, 09:00:36 am »
And sorry if the tone of my answers is a bit "in da face".

CodeBlocks rocks...really...It's light and is nearly(for the portability) exactly what I needed.Great work..

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Portability
« Reply #21 on: May 11, 2006, 09:25:16 am »
Well, you can do that by using a profile name other than default, as Game Ender wrote above. :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mmebane

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Portability
« Reply #22 on: July 01, 2006, 06:34:32 pm »
Just create an empty file named default.conf on your USB stick and you 're ready to go.

I just tried that with the June 30 nightly, but it didn't work. I deleted the codeblocks folder in my Application Data folder, created an empty file named default.conf in the same folder as codeblocks.exe on my USB drive. However, CodeBlocks doesn't start up. It creates an empty file named codeblocks.RPT then closes.

Should doing this still work? If so, I'll file a bug.