# Laminas migration symlink problem

**URL:** <https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353>\
**Category:** Migration\
**Created:** [January 31, 2020, 3:13pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353 "2020-01-31T15:13:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://discourse.laminas.dev/u/peter)\
**Post date:** [January 31, 2020, 3:13pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/1 "2020-01-31T15:13:35Z")

</div>

We run an application which works for 32 websites. That means that we have 32 different configurations. In each of these config folders under autoload there is a symlink pointing to a file outside the app.

The laminas migration fails with this file. The error message per symlink:  
Notice: file\_get\_contents(): read of 8192 bytes failed with errno=21 Is a directory in /…/.composer/vendor/laminas/laminas-migration/src/MigrateProject.php on line 67

The migration then creates a folder containing the symlinked file for each configuration. It is removed from the original location and moved to this new folder in the application root.

I’ve solved the problem by deleting all folders created by the laminas-migration and put the symlinked files back to their original location.

It looks like the migration tries to perform a replacement on this symlink. I’m only testing locally at the moment. It would be nice if this bug would be fixed.

Peter

---

<div class="post-metadata">

**Author:** ![ocramius](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ocramius/32/23_2.png) [@ocramius](https://discourse.laminas.dev/u/ocramius)\
**Post date:** [January 31, 2020, 3:24pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/2 "2020-01-31T15:24:46Z")

</div>

Hey Peter,

I’d suggest starting with an upstream patch with just a failing test case.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://discourse.laminas.dev/u/peter)\
**Post date:** [February 4, 2020, 9:23am UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/3 "2020-02-04T09:23:21Z")

</div>

In the same app in the public folder we have a symlink to an img folder outside the app. this folder has been completely deleted by the migration! i.e. the folder and all images it contains.

There are two more symlinks in the public folder. But these symlinks are pointing to folders which are inside the app. They were not deleted. Only the folder which the symlink points to a folder outside the app was deleted.

So it looks like the migration can’t handle symlinks which point to a folder or a file outside the app.

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [February 4, 2020, 2:49pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/4 "2020-02-04T14:49:34Z")

</div>

Can you provide a bit more information, please?

- What were the names of the symlinks?
- Were they absolute or relative paths?

The migration tooling is setup to do the following:

- Remove the `composer.lock` and `vendor/` subdirectory.
- Rename files that contain strings in our replacement list.

Thus the reason for my questions — I’m curious if the symlink names contained one of those strings.

We need this information so we can try and reproduce the issue, which is the first step towards creating a fix for it.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://discourse.laminas.dev/u/peter)\
**Post date:** [February 4, 2020, 3:11pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/5 "2020-02-04T15:11:02Z")

</div>

We had two problems.

The first in the config folder under autoload. A symlink to a file called “navigation.global.php”. The symlink name is navigation-de.global.php. It’s an absolute path.

The second is a symlink to a folder called “img-dyn”. The symlink name is img-dyn. And here it is a relative path.

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [February 4, 2020, 6:24pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/6 "2020-02-04T18:24:14Z")

</div>

Where was the second symlink located? And was the relative path _inside_ our _outside_ the project? (Trying to get as specific as possible so we can reproduce accurately.)

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://discourse.laminas.dev/u/peter)\
**Post date:** [February 5, 2020, 7:44am UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/7 "2020-02-05T07:44:06Z")

</div>

The second symlink is located in the public folder with a relative path outside the project:  
…/…/another-project/public/img-dyn

The first one is located in the config folder with a absolute path outside the project:  
/Users/username/www/project/data/shared/cms/project-name/navigation/de/navigation.global.php  
Since we provide several websites with this app, it should be mentioned that the config folder is a subfolder of the config folder:  
/project/config/config-project-name/autoload/symlink-to-file  
/project/config/config-another-project-name/autoload/symlink-to-file …

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [February 5, 2020, 8:20pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/8 "2020-02-05T20:20:09Z")

</div>

To test this, I did the following:

- I went into my `$HOME/tmp directory`
- I created a directory named `another-project/img-dyn`
- I created two files under `another-project/img-dyn`
- I created a file `navigation-de.global.php`
- I ran `composer create-project zendframework/skeleton-application project`, and chose defaults.
- I ran `cd project/config/autoload && ln -s $HOME?tmp/navigation-de.global.php navigation.global.php`
- I ran `cd project/public && ln -s ../../another-project/img-dyn`
- I ran `cd project && laminas-migration migrate .`

When I was done, the symlinks were still present, as were the original targets. The files under `$HOME/tmp/another-project/img-dyn` were still present.

What I _did_ see, however, were two warnings from PHP during the migration for `rename()` operations for those two symlinks, indicating that the `img-dyn` directory was not empty, and that when trying to rename the `navigation.global.php` file it was “Not a directory”.

I suspect that the issues you are seeing are OS specific; however, the errors I saw should likely be addressed. I’ll create a ticket and link you to it.

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [February 5, 2020, 8:27pm UTC](https://discourse.laminas.dev/t/laminas-migration-symlink-problem/1353/9 "2020-02-05T20:27:56Z")

</div>

I’ve created the issue here: [https://github.com/laminas/laminas-migration/issues/36](https://github.com/laminas/laminas-migration/issues/36)
