Hello!

I installed omega on a clean fresh installed drupal and made a subtheme:

drush omega-wizard
Please enter the name of the new sub-theme [Omega Subtheme]: test
Please enter a machine-readable name for your new theme [test]: test
Please choose a base theme for your new theme
 [0]  :  Cancel 
 [1]  :  Omega  

1
Please choose a starterkit for your new theme
 [0]  :  Cancel                                                                                 
 [1]  :  Extended: This is a short description for the Extended starterkit. (Provided by Omega) 
 [2]  :  Default: This is a short description for the Default starterkit. (Provided by Omega)   

1
Please choose a destination. This is where your sub-theme will be placed
Please choose a destination type.
 [0]  :  Cancel                             
 [1]  :  Site (e.g. 'all' or 'example.com') 
 [2]  :  Installation profile               
 [3]  :  Parent theme                       

1
Please choose a site.
 [0]  :  Cancel 
 [1]  :  all    

1
Do you want to keep the starterkit's readme files? (y/n): y
Do you want to enable your new theme? (y/n): y
Do you want to make your new theme the default theme? (y/n): y
You have successfully created the theme test (test) in sites/all/themes.  

When I try to execute some drush commands after setting the newly build omegasubtheme as default I get

drush cc
Drush command terminated abnormally due to an unrecoverable error.                                                                                      [error]
Error: Cannot redeclare omega_theme_get_setting() (previously declared in
.../sites/all/themes/omega/includes/omega.inc:35) in
.../sites/all/themes/omega/includes/omega.inc, line 59

Fatal error: Cannot redeclare omega_theme_get_setting() (previously declared in .../sites/all/themes/omega/includes/omega.inc:35) in .../sites/all/themes/omega/includes/omega.inc on line 59

Any idea to solve that problem would be great.

Thanks, Marc

CommentFileSizeAuthor
#42 2026149_42.patch526 bytesscor
#20 1993202-20.patch19.67 KBfubhy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fubhy’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have Omega Tools or a stale Omega 3.x lying around somewhere?

dernetzjaeger’s picture

Hello!

There is no Omega Tools or Omega 3.x in that installation.
I just made a clean installation, because I read about problems with Omega 4.x and Omega Tools
Something like "can't find Omega basetheme" happened, as I tried to install Omega 4.x in my Development installation with Omega Tools and many other modules enabled.
Therefor I tried Omega 4.x in a clean installation, just to exclude incompatibilities with other modules.

fubhy’s picture

Version: 7.x-4.0-beta4 » 7.x-4.x-dev

Do you have some sort of APC caching installed on your server that might be causing this? Also, please always test with Omega 4.x-dev at this point in the release cycle. That version has the latest fixes. Although this does not seem to be Omega but some other code trying to include Omega twice for some reason.

Try "drush cc drush" to clear your drush cache. Maybe Omega Tools/Omega 3.x is still in there.

dernetzjaeger’s picture

APC or any other caching is turned off.

The latest dev is 7.x-4.0-beta3+16-dev dated from 2013-Jun-07, while 7.x-4.0-beta4 is from 2013-Jun-09. So the beta might be newer, I think.

I also tried git clone and the newest core dev.

drush cc drush brings the error above, with omega or subtheme set as default theme.
I switched back to bartik and the cleaned caches. After switching back to any omega 4 theme, the error is the same, when I try to execute some drush.

Fatal error: Cannot redeclare omega_theme_get_setting() (previously declared in /Users/marc/Sites/localhost/omegatest/sites/all/themes/omega/includes/omega.inc:35) in /users/marc/sites/localhost/omegatest/sites/all/themes/omega/includes/omega.inc on line 59

It's exactly the same file....

line 35 is:

function omega_theme_get_setting($setting_name, $default = NULL, $theme = NULL) {

and line 59 is the closing bracket for exactly the same function.

fubhy’s picture

What version of drush are you using? Does the subtheme work in the browser or does it lead to the same error? Try to upgrade to the latest drush version.

dernetzjaeger’s picture

I used drush 5.8 and updated to 5.9
It's exactly the same error.

In the browser, there are no errors. It's also possible to clean caches from there.

I just testet omega 4 and drush 5.8 on my prod. server and I had no problems and errors.

So the problem must be on my local server.

fubhy’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Yeah. Has to be. I really don't know what's wrong then. But I've not seen this error with 4.x so far I think. Please check your local setup for any odd things going on. Sorry

dernetzjaeger’s picture

Thanks a lot!
I need to investigate what's wrong on my local system.

kendouglass’s picture

I am also getting this error.

Under sites/all/themes/, I have omega-7.x-4.0-beta4.

Under sites/mysite/themes/, I have an older omega sub-theme along with its parent theme, omega-7.x-3.1. When I am in this site folder, I can't use any drush commands without getting this error:

PHP Fatal error: Cannot redeclare omega_theme_get_setting() (previously declared in /home/drupal/7/sites/all/themes/omega/includes/omega.inc:35) in /home/drupal/7/sites/mysite.org/themes/omega/omega/includes/omega.inc on line 29
Drush command terminated abnormally due to an unrecoverable error.
Error: Cannot redeclare omega_theme_get_setting() (previously declared in /home/drupal/7/sites/all/themes/omega/includes/omega.inc:35) in /home/drupal/drupal7/sites/mysite.org/themes/omega/omega/includes/omega.inc, line 29

The v3 & v4 versions have got to be able to co-exist because it's not a simple matter to upgrade my v3 sites. For now, I'm renaming omega_theme_get_setting() to omega3_theme_get_setting() in the v3 versions. This fixes the problem.

dernetzjaeger’s picture

Thanks for your comment!

In my case there is no Omega 3.x in any subsite, because it's a clean installation with only Omega 4.x and a Omega subtheme installed at site/all/themes.

But in my local environment are other drupal installations with omega 3.x installed, but that installations should not have any influence on the clean drupal with omega 4.x installed.

So, that error is absolutely confusing to me. :(

kclarkson’s picture

I am also receiving this error after cloning a site from Pantheon and then using the wizard to create a sub theme.

I am using MAMP

dernetzjaeger’s picture

I'm using MAMP, too.

So, what's your Version of MAMP and PHP?
The solution might be to change MAMP version.
On my ubuntu prod. Server I don't have that error and I can't remember that error before updating MAMP.

dernetzjaeger’s picture

I fixed it! :D

The solution was simple but absolutely stupid and has nothing to do with Omega.

The solution:
I'm on OSX and the path to my drupal installations is Users/name/Sites/...
In OSX Terminal the path was users/name/sites/... when I executed any drush commands.

So... for everyone who is on OSX and gets some kind of "Can not redeclare" errors when trying to use drush commands, check your path.

Thanks for your helps!
I'm happy now :)

kclarkson’s picture

What did u do to fix this ?

dernetzjaeger’s picture

If your drupal installations are in a path like /Users/name/Sites you just need to check if you payed attention for case sensitive letters when you navigate to that path in the OSX terminal.

e.g. cd /Users/name/Sites with upper case U and S
instead of cd users/name/sites

For OSX it seems to be the same, but not for drush.

jedi_master’s picture

I resolved it by disabling omega theme

fubhy’s picture

Status: Closed (cannot reproduce) » Active

Someone else has been posting about the same problem over at #2034527: Omega 4 breaks Drush... Wondering where this problem comes from. It must be something with the system setup / php-cli / drush version, whatever. I can't reproduce it at all.

I resolved it by disabling omega theme

Yeah, umh, that's not a solution :P

PI_Ron’s picture

I can confirm this bug and also that the solution provided by dasmoermel in #15 works.

When navigating to my sites root in terminal like: cd ~/sites/omega-testing I get the error (actual path is ~/Sites/omega-testing)

If I use my drush alias which has the path with correct capitalisations the errors don't output.

fubhy’s picture

Priority: Normal » Major

This is a Bug somewhere outside omega and probalbly even something outside of Drupal related to CLI. We can add a wirkaround here though.

fubhy’s picture

Status: Active » Needs review
FileSize
19.67 KB

Does this work for you guys?

fubhy’s picture

Status: Needs review » Fixed

Verified that this works at least for my co-worker.

Committed to 4.x-dev

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

MrPaulDriver’s picture

I am finding this problem with the full release 7.x-4.0.

Likewise using OSX and workaround at #15 works for me. Is the commit at #21 in the full release or should I check dev?

fubhy’s picture

The patch you see in #21 is from Drupal 8 Core and was just accidently uploaded to this issue :P.

We can't do anything about this on the Omega side though. Repeat: This is not a Omega bug! Please file an Issue for Drush if you keep getting this error or changing your directory names.

samwillc’s picture

#15 fixes it for me too, thanks. I had one capital letter in path that I missed out.

karolus’s picture

Title: Error: Cannot redeclare omega_theme_get_setting() » Error: Cannot redeclare omega_theme_get_setting()-Resolution
Version: 7.x-4.x-dev » 7.x-4.0
Component: Code » Drush Integration

Thanks--
This (#15) resolved the issue for me. Since Fubhy had suggested reporting the bug to Drush, I already submitted a bug ticket regarding this in their GitHub repository.

tonypbarker’s picture

Using Mac OSX too, #15 didn't make any difference for me, disabling my subtheme to use drush currently.

mdm172’s picture

fubhy,
I just received this error tonight while setting up a fresh drupal install.

At first I used the recommended "drush dl omega" while in /sites/all/themes folder. Omega wasn't there. I then manually placed omega (and ohm) in the folder, owiz'ed my sub-theme, set it up and tried to "omega-export" and received this error.

I looked for a reason for a while until finally I went to home/.drush. Omega and Ohm folders were there (I assume from my original drush attempt). I deleted these folders and the error disappeared.
There may be another issue why "drush dl omega" didn't work. (I haven't looked here). But is it possible there's a problem with that command and that's what caused the error?

Cheers
Michael

fubhy’s picture

This might very well be related to the latest drupal.org changes (Upgrade to D7). Some drush dl weirdness has been reported since. Thanks for mentioning and posting this here. Might be helpful for others who encounter the same problem.

Rodge Darkfleet’s picture

I'm experiencing the same problem on osX.

I made an omega sub theme and enabled it. Tried to drush dl module and got the same error.

However, when I disable my omega sub theme and omega, the error disappears! Re-enable the sub theme gives me the same error again.

mdm172’s picture

@Rodge
I apologize if you already knew this but...
I had a similar issue unrelated to Omega trying to use the dl command. I instead used: drush en foo-module -y
Since it doesn't find the module locally (duh) it it then asks if you want to dl and enable it. Fixed my issue.
One of the many benefits of sitting through Fuhby's 3 hour Omega4 video. ;-)

adam-delaney’s picture

I am experiencing this issue also. I have verified that my path is correct so this does not seem to be a case sensitive issue. This appears to be an issue when you have two copies of the omega theme. I have the omega base theme in 2 locations. e.g. site/all/themes/omega and also in sites/mysite/themes/omega. I don't even have my subtheme enabled and I am still getting this error when attempting to clear my site's cache using drush.

adam-delaney’s picture

Issue summary: View changes
Status: Closed (fixed) » Active
fubhy’s picture

Priority: Major » Minor
Status: Active » Closed (won't fix)

Possibly, yes. At least that sounds like a good explanation for the problem you are having (Omega in two directories). In that case, this is a Drush bug. Please file a bug report against the Drush github issue queue: https://github.com/drush-ops/drush/issues

I can't do anything (legit, as in "non-hacky") to fix this on the side of Omega so the only thing I can do at this point is to direct you to the Drush issue queue, sorry.

I don't even have my subtheme enabled and I am still getting this error when attempting to clear my site's cache using drush.

Yeah. The enabled/disabled states for themes is a lie. It has 0 effect in Drupal 7. And neither Drupal, nor Drush care for it. Which (in Drush's case makes sense, because... Why would it care if even Drupal core itself doesn't?). I hope that this will get fixed in D8, however, in D7 we have to live with the fact that Enabling/Disabling themes essentially makes no difference. The only two settings that matter really are "Which theme is the default theme?" and "Which theme is the admin theme?".

So... Yeah, => Drush issue queue :(.

mowen3’s picture

Im experiencing the same issue. I believe I have set up everything according to the guidelines in Omega 4 and have downloaded the latest version of drush from github. I have managed to create a new subtheme using the drush-owiz command which worked but cannot get any further due to the error below:

I am trying to use drush omega-guard to set up the correct updating of scss files into css files for a drush/Omega 4 installation but receive the following errors:

Error: Cannot redeclare omega_theme_get_setting() (previously
declared in
.../master/sites/all/themes/omega/omega/includes/omega.inc:35)
in
.../master/sites/all/themes/omega/omega/includes/omega.inc,
line 60

I want to use Omega as I like the structure but without this resolution, I will need to find another responsive theme. Any help much appreciated. Is there any workaround to this while a longer term fix is put in place.

Martin

fubhy’s picture

This error only occurs if you have Omega Tools installed which you shouldn't (if you are using Omega 4). Omega itself *never* loads the file (omega.inc) more than once as it exclusively uses 'require_once' to load it whenever needed (making it so that it would never trigger this error).

The other case where this happens is when using Drush with Omega set up in multiple directories (e.g. multisite with Omega 3 and Omega 4 side-by-side). In that case we really can't do anything because that is simply not supported (or it has to be fixed in Drush, not Omega).

To work around it, though, you could simply avoid "drush omega-guard" and instead directly "bundle exec guard" directly (omega-guard is just a wrapper for that command but pipes it through drush so you don't have to navigate to the theme directory.. that's about it). So: Use "bundle exec guard" in your theme's directory instead.

mowen3’s picture

My situation is your second use case: omega 3 and 4 set up in multiple directories. However, just tried your suggestion and it works. Many thanks for your prompt response.

tonypbarker’s picture

Hi fubhy. Re: #36

I still have the issue that drush is not working at all with Omega enabled but

- Haven't been using Omega Tools
- Do not have more than one instance of Omega, not using multisite either
- Already using bundle exec guard

codybarr’s picture

Wow, yeah, #15 worked for me. That's dumb.

mrP’s picture

same issues as #9.

Screenack’s picture

As per #34 I've added a ticket to the Drush github issue queue here: https://github.com/drush-ops/drush/issues/709 as it relates to multiple copies of Omega (sites/all and sites/multisite) causing drush to fail

scor’s picture

Status: Closed (won't fix) » Needs review
FileSize
526 bytes

I encountered the same problem today. From my understanding, it's due to the fact that drush will scan and include as many drush command files as possible regardless of the ones which are enabled in Drupal and included in a typical Drupal bootstrap. Drush does it that way for performance reasons. On my setup, I had 2 copies of omega, both in sites/all/themes:
- sites/all/themes/omega/
- sites/all/themes/omega-two/
(it doesn't really matter where there are, I believe it's the same problem if one is in sites/all/themes and the other in sites/mysite/themes).

In my setup, Drush first includes omega.drush.inc from the omega-two copy. omega.drush.inc starts like this:

if (!function_exists('omega_theme_get_setting')) {
  require_once dirname(__FILE__) . '/omega.inc';
}

at this point, sites/all/themes/omega-two/omega/includes/omega.inc has been included, and therefore omega_theme_get_setting() is defined.

Later on, Drush reaches the point where it invokes _drush_bootstrap_drupal_full(), which loads omega's template.php, which starts with:
require_once dirname(__FILE__) . '/includes/omega.inc';
It's a require_once, but that doesn't matter because the omega.inc file which was loaded previously came from a different copy of omeg. So from PHP's standpoint, it's a different file and therefore it will be included, which causes the Cannot redeclare omega_theme_get_setting PHP fatal error.

I'd recommend to possibly consider patching omega with the attached patch.

fubhy’s picture

Yeah that makes sense!

samuraijack’s picture

As per #38 I had the same problem and it concerned the version of "ruby". I have version 2.1.1 instead of 1.9.3 and to get rid of this error, you should change the files .ruby-version in Omega theme and created by you Sub-theme.
[ Written with the help of translate.google ]

Perignon’s picture

#42 was a great fix.

dsoini’s picture

#42 does not work for me. Drush still gives me the error even if I put the patch in both sites/all/omega and sites/mysite/omega. The site seems to work though even without the patch.

DamienMcKenna’s picture

Version: 7.x-4.0 » 7.x-4.x-dev
Status: Needs review » Reviewed & tested by the community

The patch in #42 is short & simple, I suggest committing it.

As for other issues, I suspect there may be a problem having two copies of the same codebase accessible to Drush, and that there may be a bug in Drush triggering it, it certainly should only be loading one copy of the theme's files.

robbdavis’s picture

Cannot redeclare omega_theme_get_setting()

For me the problem stems from having two version of omega; one in the profile I'm using and one in regular sites/all/themes/omega directory. Omega needed to be in both locations to get omega-guard working.

The problem is when you close down your computer (and shut off the omega-guard tools) and then try to start them up again, there is a conflict because there are two versions of Omega.

It looks like the patch might solve this problem. But to solve it without patching, remove the omega directory from sites/all/themes, flush all the caches, put the directory back in sites all theme, flush all caches, then run omega-guard. It should fire up again. Hope this helps someone.

R.

supadits’s picture

#15 fix my problem

osx 10.11.5
drush 7.3.0
php 5.5.25
drupal 7.43