Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Finder]Solaris has older find command, S2.2 will not run. #7061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ahundiak opened this issue Feb 13, 2013 · 11 comments
Closed

[Finder]Solaris has older find command, S2.2 will not run. #7061

ahundiak opened this issue Feb 13, 2013 · 11 comments

Comments

@ahundiak
Copy link
Contributor

By default, Sun (well Oracle) Solaris has it's own find command which does not support gnu find options such as -noleaf or -regexptype. So S2.2 does not work out of the box.

A simple patch to Finder::Shell with a check for PHP_OS=sunos will fix the problem. I can prepare one if need be.

However, I think the problem is more generic. It's same issue as when you attempt to do browser detection. You still never know if the system will support a command until you test for it. In the case of solaris, you could install a gnu find command in which case all would be well.

I think an actual version test for find (or gfind) would be better than os sniffing.

I see that there was also a proposal to make a finder factory service. That would allow the option of specifying which adapter to use. Makes things real simple.

@stof
Copy link
Member

stof commented Feb 13, 2013

The finder cannot be a service. Finders are not stateless. You cannot use the same instance to search several times

@ahundiak
Copy link
Contributor Author

Fair enough. I added the word factory to my original post.

@danieljames
Copy link

I had a similar problem, because I'm using GNU find on a Mac (which I have to admit is a bit of a weird edge case). When running composer with symfony I get a lot of errors saying:

find: unknown predicate `-E'

Annoyingly, the error isn't detected in php because the output of find is piped into another command (the return status from exec is taken from the last executable in the pipe).

It'd be good enough just to have a way to force it to use the pure php implementation.

@stof
Copy link
Member

stof commented Feb 18, 2013

$finder->removeAdapters()->addAdapter(new PhpAdapter());

@ahundiak
Copy link
Contributor Author

Is there a hook somewhere in S2.2 to allow setting the PhpAdapter?

This is actually quite puzzling. The finder component does not work on many operating systems out of the box. You would think it would be better to default to the safe implementation and then allow the user the option to use a faster one if available.

Imagine a new S2 developer bringing down S2 and getting this strange error. I suspect they would look elsewhere for their framework. And if they did investigate then they would realize they need to hack a core component just to get started. Not an ideal introduction to Symfony.

@stof
Copy link
Member

stof commented Feb 18, 2013

@ahundiak Please read my comment just above to see how to force using the PhpAdapter

@danieljames
Copy link

The problem is that the Finder is created and used in code that we don't have control over (i.e. Symfony itself). So we can't run the code you use. We need to force it to use PhpAdapter everywhere, not just in our own code.

One means might be a configuration mechanism. Now I suppose this is tricky for anything that's run from the composer install, since that happens before there is a chance to make configuration changes (unless there's a global config?) so it might be best if the Symfony installation code always does that. And then the configuration checker could perhaps try calling find to see if it works (without any piped output).

It would be better if such things worked without configuration, but I appreciate that can be tricky. As the original poster said, the best thing to do is to test the find itself. But annoyingly, find doesn't offer an easy way to do that (there's nothing along the lines of 'find --version'). So such a solution is liable to be either fragile or expensive.

Anyway, I'm new to Symfony, so I don't know exactly what is feasible.

@jfsimon
Copy link
Contributor

jfsimon commented Feb 23, 2013

@ahundiak your idea of a finder factory as service sounds good for me.

It could permit to:

  • store adapters cache in application cache
  • have only PhpAdapter by default and add a better one by configuration

The second point seems required because of the many problems encountered on specific plateforms and the difficulty to guess which shell commands/options are available.

What do you guys think of this?
@fabpot do you think this could cause issues?

@jfsimon
Copy link
Contributor

jfsimon commented Feb 28, 2013

@ahundiak the PR #7212 will set the php as default adapter.
Would you like to work on a sun_solaris adapter?

@ahundiak
Copy link
Contributor Author

ahundiak commented Mar 1, 2013

While I am not opposed to the idea I'm not sure it's worth the investment. My Solaris workstations run fine with the default php adapter. Actual production servers might benefit but how many solaris servers are really out there? Now that 2.2 is released if anyone else has problems with solaris then I'll step in.

One thing to keep in mind is that you can load gnu find on solaris and end up with a gfind command which will not interfere with he existing solaris find command. So there should also be a way to configure the name of the find command in which case the existing gnu find based adapter works great.

@fabpot
Copy link
Member

fabpot commented Jun 13, 2013

Closing as a workaround has been found now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants