Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Duplicate declaration, File is already declared in file #378

Closed
Dagnan opened this issue Aug 6, 2013 · 9 comments
Closed

Duplicate declaration, File is already declared in file #378

Dagnan opened this issue Aug 6, 2013 · 9 comments

Comments

@Dagnan
Copy link

Dagnan commented Aug 6, 2013

Hi.

I' m trying to setup Boxen.

The full error is:

Error: Duplicate declaration: File[/Users/michel/.gemrc] is already declared in file /opt/boxen/repo/shared/boxen/manifests/gemrc.pp:10; cannot redeclare at /opt/boxen/repo/modules/people/manifests/dagnan.pp:65 on node macbook-air-de-michel-2.local
Error: Duplicate declaration: File[/Users/michel/.gemrc] is already declared in file /opt/boxen/repo/shared/boxen/manifests/gemrc.pp:10; cannot redeclare at /opt/boxen/repo/modules/people/manifests/dagnan.pp:65 on node macbook-air-de-michel-2.local

The file from where the problemes comes is https://github.com/Dagnan/fidzup-boxen/blob/master/modules/people/manifests/dagnan.pp

The gemrc is only declared once so I don't really understand what the problem is.

And after fixing it, what would be the correct way to relaunch boxes? Just script/boxen? Or nuking it before? Thanks!

@mdelagrange
Copy link
Contributor

Boxen already generates a .gemrc by default: https://github.com/boxen/puppet-boxen/blob/master/manifests/gemrc.pp Puppet will not attempt to create the same file twice. I worked around this by manipulating the existing .gemrc file instead. In my case something like:

class myorg::gemrc {

  exec { 'add internal gems server':
    command => 'gem source -a http://gems.myorg.com',
    unless  => "grep 'http://gems.myorg.com' /Users/${::boxen_user}/.gemrc",
    user    => $::boxen_user
  }

  exec { 'correct gem sources order':
    command     => 'gem sources -r http://rubygems.org/ && gem sources -a http://rubygems.org/',
    subscribe   => Exec['add internal gems server'],
    refreshonly => true,
    user        => $::boxen_user
  }

}

@Dagnan
Copy link
Author

Dagnan commented Aug 7, 2013

Oh thanks @mdelagralfo. Seems to me that this could be a common problem. Should not your answer be in a FAQ or something?

And actually I don't really know how I can use your solution to create a symlink to my file :|

@jozefizso
Copy link

Hey @Dagnan, you can overwrite the .gemrc definition form puppet-boxen like this: boxen/puppet-boxen#36 (comment)

@Dagnan
Copy link
Author

Dagnan commented Aug 8, 2013

@jozefizso Thanks. But that way I have to put the gemrc file in the boxen repo right?
I tried to change the definition of what is given in this PR to create a symlink but did not succeed.

@jozefizso
Copy link

Try this if you need to create symlink to ~/.gemrc:

File <| title == "/Users/${::boxen_user}/.gemrc" |> {
  ensure => 'link',
  target => "~/.mygemrc"
}

I'm not sure if this definition will override whole file definition, or you will have to somehow discard the source parameter from original definition. But you should by able to define .gemrc as symlink instead of managing it as template in your boxen repo.

@mdelagrange
Copy link
Contributor

I'm not sure if this definition will override whole file definition, or you will have to somehow discard the source parameter from original definition. But you should by able to define .gemrc as symlink instead of managing it as template in your boxen repo.

Setting it to undef might work. I didn't know about collectors in Puppet. Cool!

@seanknox
Copy link
Contributor

@Dagnan can this issue be closed?

@Dagnan
Copy link
Author

Dagnan commented Mar 21, 2015

I can't remember what I did or not, anyway you can close it. Thanks!

@seanknox
Copy link
Contributor

I'm not a maintainer. Do you mind closing?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants