Why are my p-values for lognormal distribution mean not uniform? I was wondering why my p-values for lognormal distribution are not uniform while using t-test for mean. Here is my code:
set.seed(1234)
sims <- 5000
pvals <- vector(length=sims)

for(i in 1:sims){
  dist <- rlnorm(30)
  pvals[i] <- t.test(dist, mu=exp(0.5))$p.value
}

pvals %>% hist


The p-values look right-skewed but the lognormal distributions I generated should have mean = exp(0.5) based on the input parameters right? So then the null hypothesis is true so the p-values should be uniform. I'm not sure what I did wrong here.


the null hypothesis is true so the p-values should be uniform. I'm not sure what I did wrong here.

That would only be the case if the assumptions of the test were met. For a one-sample t-test, Wikipedia says: "Although the parent population does not need to be normally distributed, the distribution of the population of sample means $\bar {x}$ is assumed to be normal."
The following modification of your code shows the problem:
set.seed(1234)
sims<-5000
means<-vector(length=sims)
for(i in 1:sims){
   dist<-rlnorm(30);
   means[i]<-mean(dist)}
plot(density(means),bty="n",main="")


With this sample size, you have substantial skew in the distribution of sample means. So the t-test assumption of a normal distribution of sample means isn't met. The central limit theorem doesn't come to the rescue in this case until you have larger sample sizes. Play with the sample size to investigate further.
In response to comment
The above was just intended to suggest that if the assumptions of a test aren't met then you shouldn't be surprised if you don't get proper coverage. Glen_b rightly notes in comments that the specific answer to the question is contained in the distribution of t-statistics. Here it is:

Again, large skew with nearly 12% of observed t-statistics outside the 95% CI, mostly on the left tail (584 below qt(0.025,29), 11 above qt(0.975,29)). Admittedly, one shouldn't put too much weight on a single simulation like this. I haven't thought through a theoretical basis for the sampling distribution of t-statistics with a lognormal distribution, although I suspect there's one somewhere in the literature.
The code:
set.seed(1234)
sims<-5000
tvals<-vector(length=sims)
for(i in 1:sims){
  dist<-rlnorm(30);
  tvals[i]<-(mean(dist)-exp(0.5))/(sd(dist)/sqrt(30))
}

plot(density(tvals),bty="n",ylim=c(0,0.4),xlim=c(-5,3),main="t-value distribution")
curve(dt(x,df=29),from=-5,to=3,col="red",add=TRUE)
abline(v=c(qt(0.025,29),qt(0.975,29)),lty=2,col="red")
legend("topleft",bty="n",legend="black, observed\nred, theoretical\ndashed, 95% limits")

sum(tvals<qt(0.025,29))
# [1] 584
sum(tvals>qt(0.975,29))
# [1] 11

